Skip to content

Instantly share code, notes, and snippets.

@sometimescasey
Last active July 1, 2021 22:26
Show Gist options
  • Save sometimescasey/f0d436a9dea5d3dc346378075a73150a to your computer and use it in GitHub Desktop.
Save sometimescasey/f0d436a9dea5d3dc346378075a73150a to your computer and use it in GitHub Desktop.
Django Heroku Setup notes

Django Heroku setup notes

How to do normal Django manage commands?

I.e. create superuser, check migrations, run migrations...

Also, don't make migrations on the Heroku machine. Make them locally and commit to version control.

heroku run python manage.py showmigrations --app myapp
heroku run python manage.py migrate --app myapp
heroku run python manage.py createsuperuser --app myapp

Note that running heroku ps:exec per this page won't work because none of your environment variables will be set.

migrate runs migrations, but then migrations are empty?

Or you get the sqlite3.OperationalError: no such table: auth_user issue when trying to createsuperuser?

Couple of points:

Migrations not automatically running with each deployment?

Ensure the migrate command is at the top of the Procfile at directory root:

release: python manage.py migrate
web: gunicorn myapp.wsgi --log-file -

Other weird quibbles

IntegerField for sqlite3 accepts larger values than Postgresql. If storing large integers, consider BigIntegerField or CharField. https://stackoverflow.com/questions/11302711/integer-out-of-range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment