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.
Or you get the sqlite3.OperationalError: no such table: auth_user
issue when trying to createsuperuser
?
Couple of points:
- Heroku doesn't use sqlite3, so make sure you .gitignore your db.sqlite3 file and use the postgresql add-on.
- The DATABASE_URL environment variable needs to be configured - the deploy won't work out of the box. Use https://pypi.org/project/django-heroku/ or https://pypi.org/project/dj-database-url/.
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 -
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