Search code examples
djangovalidationauthenticationadminvalidationerror

Django admin calling the ```.save()``` method when trying to log in to the admin site


The auth user model extends AbstractUser and overrides the .save() method. The model contains two mandatory and unique fields. It also calls .full_clean() in the .save() method. The problem arises when an admin tries to log in. Django throws a validation error saying those two fields can't be blank. The error goes away when .full_clean() is commented out.

Why does Django admin call the .save() method while trying to log in to the admin site?


Solution

  • I expect the .save() is called to store the last_login field for the user. This is also why it's running the validation.