django: cannot import settings, cannot login to admin, cannot change admin password
Posted
by
xpanta
on Stack Overflow
See other posts from Stack Overflow
or by xpanta
Published on 2010-12-31T06:48:22Z
Indexed on
2010/12/31
6:53 UTC
Read the original article
Hit count: 350
Hi,
It seems that I am completely lost here. Yesterday I noticed that I cannot login to the admin panel (don't use it much, so it's been some weeks since last login). I thought that I might have changed the admin password and now I can't remember it (though I doubt it).
I tried django-admin.py changepassword (using django 1.2.1) but it said that 'changepassword' is unknown command (I have all the necessary imports in my settings.py. Admin interface used to work ok).
Then I gave a django-admin.py validate. Then the hell begun. django-admin.py validate gave me this error: Error: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
I then gave a set DJANGO_SETTINGS_MODULE=myproject.settings
and then again a django-admin.py validate
This is what I get now: Error: Could not import settings 'myproject.settings' (Is it on sys.path? Does it have syntax errors?): No module named myproject.settings
and now I am lost. I tried django console and sys.path.append('c:\workspace') or sys.append('c:\workspace\myproject') but still get the same errors.
I use windows 7 and my project dir is c:\workspace. I don't use a PYTHONPATH variable (although I tried setting it temporarily to C:\workspace but I still get the same error). I don't use Apache, just the django development server.
What am I doing wrong? My web page works fine. I think that the fact that I can't login as admin is related to the previous import error, no?
PS: I also tried this: http://coderseye.com/2007/howto-reset-the-admin-password-in-django.html but still I couldn't change admin password for some reason. Although I could create another admin user (with which I couldn't login).
© Stack Overflow or respective owner