Null value in last_login column violates non-empty constraint

Having problems getting rid of this error.

I am trying to use Digital Ocean to deploy a Django application. I have configured Postgres, but when I try to register a new user in my application, I get this problem.

I tried working python manage.py makemigrations and python manage.py migrate and they work fine. SQL migration ends after migration.

+5
source share
2 answers

Try adding this to your import:

 from django.utils import timezone 

Then, wherever you bind the user data to save to the new user before the save procedure:

 <user_object>.last_login = timezone.now() 
+5
source

I upgraded from django 1.7 to django 1.10 when I came across this. What ended up was to run python manage.py migrate to update the tables and columns of the database.

+3
source

Source: https://habr.com/ru/post/1235842/


All Articles