I created a web service to deploy my simple django application using SQLite. I couldn’t log into the django admin page:
Please enter the correct username and password for a staff account. Note that both fields may be case-sensitive.
Here is my build.sh:
# exit on error
set -o errexit
pip install -r requirements.txt
# python manage.py collectstatic --no-input
python manage.py migrate
Your help is much appreciated.
Did you follow this step https://render.com/docs/deploy-django#create-django-admin-account in the Render shell after your application was deployed?
Thank you. Yes, but I didn’t use the
render.yaml approach. Luckily, I could figure out how to create a superuser automatically from the build script. I could log in to the admin page and create new data. However, render clears the data I created after every auto deploy. It seems like the database instance I created on render doesn’t save the data.
Inside your web service, you can just click on ‘Shell’ in the left hand nav menu to get terminal access, and type ‘manage.py createsuperuser’. No need to create a super user in a build script. You can run migrations, collectstatic or anything else you want to in there will the full django environment up and running. It’s super convenient.
Render won’t clear the data if you’re using an external postgres database. If you’re using a sqlite dB on the service, then yes, it will get deleted and re-created every time you update or restart the service, since the local storage is ephemeral. You’d need to add a disk to the service and put the sqlite file on there otherwise.