[Solved]-Cannot Log in to Django Admin Interface with Heroku Deployed App


I faced the similar problem. Then I created a superuser by running:

$ heroku run python manage.py createsuperuser


$ git push -f heroku master
$ heroku run python manage.py migrate

It worked all fine.


This worked for me:

heroku run python manage.py createsuperuser -a <app_name>

After creating the superuser, refresh your app
& make sure to use a first capital letter in the username section like "Raj" instead of "raj".

Added the -a flag in front of <app_name>, without which heroku will throw an error


I am facing similar error, but however I have noticed few things in your settings.py I feel should be changed, when you are migrating to heroku the default database needs to be changed to postgresql like this

'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'mydatabase',
    'USER': 'mydatabaseuser',
    'PASSWORD': 'mypassword',
    'HOST': '',
    'PORT': '5432',


You will find these credentials in your Heroku App’s Resources tab->add-ons->postgresql->view credentials.

Refer to these links for detailed information:


This link tells you how to separate local_settings from settings:

Hope this helps!


Maybe this will help someone else.
After some thorough search on the net, I had still the issue and could not login into the admin page in production.
Therefore , I had to come up with a workaround.
I created a new user in my local environment (checked if I could log in with it on localhost, and it worked), copied the sqlite file located in the app folder,which is called db.sqlite3 , and copied it onto the production server in the same location.
Restarted the app, and i was able to login.
I came up with this after i saw on the command line that the user i just created did not exist.

heroku run python /app/src/manage.py changepassword  -a appname

which returned:

CommandError: user 'yourusername' does not exist

Leave a comment