Thursday, March 27, 2014

settings set in stone on import?

Hi,

I'm trying to create an init script for a project of mine (open source). In short, my users should be able to initialize a Django project from scratch with one command. The internal workflow of the command would go something like this:

* call startproject with a custom template
* call syncdb --noinput
* call collectstatic --noinput
* ...

The thing is, to call the startproject management command I need to indirectly import django settings, which are unset at that time. After that's done and the proper settings.py gets rendered to the filesystem, I was hoping to use those settings to call manage.py commands (syncdb and collectstatic obviously need a working, valid settings.py), but it would appear Django has already initialized itself into "no settings mode". I was also hoping to avoid doing this out of process.

Is there a way to make Django reread DJANGO_SETTINGS_MODULE after it has been imported? Also, it would seem django.core.management.call_command doesn't take a 'settings' keyword argument, like django-admin.py does.

Cheers,
Tin

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/76287152-65f4-4945-8c99-2b62825abdaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment