running migrate through views itself

20 views
Skip to first unread message

kk

unread,
Oct 12, 2015, 2:15:30 AM10/12/15
to django...@googlegroups.com
Hello all.
The financial project I am developing requires that when the user creats
on create organization. the Migrate command has to be run automatically.
I have 2 questions regarding this.
1, If I am using sqlalchemy instead of sqlobject, will the migrate
utility work?
2, If yes then how can I do this through code in a view function? if no
then is there a way to do it through sqlalchemy? or should I use the
create_all function in sqlalchemy itself?

Happy hacking.
Krishnakant.

Tim Graham

unread,
Oct 12, 2015, 10:19:17 PM10/12/15
to Django users
You can execute management commands from Python code using call_command():

https://docs.djangoproject.com/en/stable/ref/django-admin/#running-management-commands-from-your-code

It seems a bit risky to me to expose functionality to your users that allow them to change your database schema as a result of some action. This isn't really how Django is designed in terms of having models which map to database tables, but I suppose there could be use cases for doing that. I'll be curious to learn if others have done anything like you propose.

kk

unread,
Oct 12, 2015, 10:27:27 PM10/12/15
to django...@googlegroups.com
In the project, every year new books are opened and every organization has it's own database for ever every financial year.
Happy hacking.
Krishnakant.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/309f6eba-6f93-4e5e-a23e-42073e8e9c77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages