I almost finish my django web aplication, but i never using shell for it. It is hard to checking some things by making changes in code, restarting server and reloading page. But I can’t configure django settings environment or something like this.
I do:
export DJANGO_SETTINGS_MODULE=my_project.settings
Then:
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_project.settings'
Then I try:
>>> os.environ['DJANGO_SETTINGS_MODULE']
'my_project.settings'
But when I try:
>>> python
>>> import urls
I get:
ImportError: Could not import settings 'my_project.settings' (Is it on sys.path?): No module named mysite.settings
And when I try:
>>> django-admin.py shell
I get:
Error: Could not import settings 'my_project.settings' (Is it on sys.path?): No module named mysite.settings
I am frustrated because of that. The server that I am using have mod_passanger. Does someon know what is the reason of problem? Maybe mod_passanger? Or I am doiung something wrong?
You shouldn’t need to do any of this. The
manage.pyscript does it all for you, which is why you should always use it (instead of django-admin.py) once you’re inside a project.Just do this:
That’s it.