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

I am coding a web application with django and now I am starting to handle users. I'm trying to make the easy part, just creating a new admin user interface, but when I try to do this, I get an error message and I can not find information about it.

I enter the django administrator, register with the superuser, go to users, add the user. It only requests a username and password. When I submit changes, I get a NOT NULL constraint, this is:

NOT NULL constraint failed: auth_user.last_login 

I reviewed the django documentation, and there it says to create such a user:

  • from django.contrib.auth.models import User
  • user = User.objects.create_user ('john', ' lennon@thebeatles.com ', 'johnpassword')

So, I open the terminal and do "./manage.py shell" "import django" "import User", and then I try to execute this code, but it also fails, it says:

 NameError: name 'User' is not defined 

Perhaps I changed something in the first part of the project? I created models, patterns, URLs and used / static / to link to files.

Thank you for your help!

+8
source share
2 answers

last_login field changed in django 1.8 . Just start the migration

 python manage.py migrate 
+26
source

Same problem if running python manage.py migrate --fake and then python manage.py migrate and it worked fine.

+3
source

All Articles