Cannot login to django admin page after render deployment - django

I'm trying to deploy a simple django application (SQLite3) to render but I can't log in to the admin page even with valid superuser credentials. I could authenticate locally, but not while on the render deployed version.
Your help is much appreciated!

Try running python manage.py createsuperuser in the Render Shell.
Documentation on creating a Django admin account on Render deployments.

As a substitute to running python manage.py createsuperuser on Render Shell, you can do a quick deployment with python manage.py createsuperuser --no-input on your build script and have environment variables such as DJANGO_SUPERUSER_USERNAME set. You then have to remove this hack for later builds.
See https://stackoverflow.com/a/59467533/4932353 for more information.

Related

can not login in production /django

I successfully deployed my django webapp but now I am unable to login as superuser even if I put correct credentials
Screenshot
If "deployed" means a new environment, you have to migrate everything and create a new superuser.
BTW you can dump your db with
manage.py dumpdata > dump.json
and load to the new environment with:
manage.py loaddata "path/to/file/dump.json"
For more information: dumpdata and loaddata

Not getting prompt to set up superuser on Django's auth system?

I'm following a tutorial that uses Django's authentication system to log in users and when the sqlite3 db is first connected to django and the command python manage.py syncdb (tutorial is from before syncdb was deprecated) is run, I don't get this same message in the command line:
You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now?
I instead ran
python manage.py makemigrations
python manage.py migrate
and this seemed to have set up the tables
but then when I run:
select * from auth_user;
nothing is returned to me in the command line.
How can I setup a superuser from command line and get encrypted password, etc?

How to remove all data about users from database from heroku server?

I created many test accounts in my heroku server. Now they all have empty columns, and therefore do not work. And now I want to remove all data about existing users/accounts, including superuser, then recreate. How I can do this?
You can go to your terminal, where you have executed the command 'python manage.py runserver' and execute the command - 'python manange.py shell', then your shell will start.
Then execute the command:-
step-1: from django.contrib.auth.models import User
step-2: User.objects.all().delete() # this will delete all the user from your table
step-3: exit() # exit from the shell
step-4: python manage.py createsuperuser # for creating the superuser
This is totally in server side.
Go to your heroku database and reset database from the setting.
after that.
$ heroku run python manage.py makemigrations
$ heroku run python manage.py migrate
Create New Admin ( can be any or the same your existing)
All done, 100% that works for me.

Django - accidently removed superuser

I am using Django 1.4.5 and accidentally deleted the superuser. How can I recreate the superuser account for an existing project? I found tutorials that show to do it when initially setting up a project but can't figure out how to create a superuser for an existing project.
I did try django-admin.py createsuperuser in the terminal without any luck
I apprecite the time and feedback.
You can invoke this command through manage.py
./manage.py createsuperuser

django fabric syncdb

How would you run this django command to syncdb with fabric automatically.
python manage.py syncdb --settings="app.settings.test"
if tried to do run, it gets stuck at the "Do you want to create superuser account", can it passed as yes and login information with it.
run('python manage.py syncdb --settings="app.settings.%s"' % name, pty=True)
Add --noinput to the arguments to keep django-admin from prompting:
python manage.py syncdb --settings="app.settings.%s" --noinput
If you have specific credentials that you'd like to preload always, I suspect the simplest way to achieve that would be to create a data dump of the user database from a machine with (just!) the admin account loaded, and then to load that in after syncdb. Alternatively, you could simply leave out the admin account and add it later with manage.py createsuperuser when and if you need to have it.