Superuser didn't work - django

I want to create a super user to log into the admin panel, I use to do this command:
python manage.py createsuperuser
I do not use ./manage.py syncdb (I use the South).
After creating a super user, I go to the address /admin/ and enter the data you gave when creating a super user and get an error if I typed bad data.

Related

Wagtail superuser unable to log in to CMS

I'm new to Wagtail and django. I've completed the https://learnwagtail.com/wagtail-for-beginners/ course and managed to get my site up and running on Digital ocean, however I'm unable to login to the admin area. I have tried using the superuser credentials that were used locally. I have also tried multiple times to create a new superuser with:
python manage.py createsuperuser
and while the process appears to work successfully in the terminal (I'm logged in via SSH to my DO droplet), I continually receive the 'Your username and password didn't match. Please try again.' message when attempting to log in with the newly created username and password. If I use the shell to check users I can see my newly created user exists. I have also tried using
python manage.py changepassword myusername
to change the password on the previously created superusers, but again, while the process appears to work successfully in the terminal I continue to receive the error message when attempting to log in. Can anyone point me in the right direction as to what I might be missing or doing wrong here? And / or how I might best debug the issue? Thanks in advance!
You might need to set up a Site that matches the domain on which you're accessing your site. In the command line, try this:
import wagtail.core.models.sites
s=Site.objects.last()
s.hostname='yourdomain'
s.site_name='verbose site name'
s.is_default_site=True
s.save()
If you don't already have a site in the database (or just want to add another one), then do s=Site.objects.create() instead of Site.objects.last()place the three properties into thecreate` statement as keywords.
I needed to make sure my manage.py commands were picking up my production settings. So running:
DJANGO_SETTINGS_MODULE=mysite.settings.production ./manage.py createsuperuser
and NOT:
python manage.py createsuperuser was the solution.

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?

Creating users in django (NOT NULL constraint failed: auth_user.last_login)

I'm coding a web app with django and now I'm starting to handle users.
I'm trying to do the easy part, just create a new user throught admin interface, but when I try to do it I get a error and I don't find any info about it.
I enter django admin, log in with superuser, go to users, add user.
It only asks for: username and password.
When I submit changes then I get a NOT NULL constraint failed, this:
NOT NULL constraint failed: auth_user.last_login
I revised django documentation, and there it says to create a user like this:
from django.contrib.auth.models import User
user = User.objects.create_user('john', 'lennon#thebeatles.com', 'johnpassword')
So, I open a terminal, and do "./manage.py shell" "import django" "import User" and then I try this code, but fails too, it says:
NameError: name 'User' is not defined
Maybe I've changed something in the first part of the project? I've created models, templates, urls and used /static/ for references to files.
Thanks for your help!
last_login field changed in django 1.8. Just run the migrations
python manage.py migrate
Same issue, Had to run python manage.py migrate --fake and then python manage.py migrate and it worked perfectly.
In the app folder there is migration folder.. remove all files from it just keep pycache folder and init.py
then execute python manage.py migrate and then python manage.py makemigrations ..
simply we are removing the older migrations and migrating them again

Creating additional Superuser in Django 1.6

Is it possible to create more than one superusers in Django? When I create a new django app it automatically asks for creating a superuser. But I don't know how I can create more than one superuser to give admin access to other people ?
Use this command:
python manage.py createsuperuser
More: https://docs.djangoproject.com/en/dev/ref/django-admin/#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.