Skip to content
Advertisement

null value in column “last_login” violates not-null constraint

Having issues getting rid of this error.

I’m trying to use Digital Ocean to deploy my Django app. I configured Postgres, but when I’m trying to register a new user in my app, I get this problem.

I’ve tried running python manage.py makemigrations and python manage.py migrate and they work fine. The SQL migrations are completed upon migration.

Advertisement

Answer

Try add this to your imports:

from django.utils import timezone

Then wherever you grab the user‘s data to save the new user add before the save procedure:

<user_object>.last_login = timezone.now() 
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement