I'm trying to create a minimal custom user model.  The only thing I care 
about is email.  But it seems Django really wants me to set a last_login 
field.  Can I avoid it somehow?

Here's the minimal repro:

https://github.com/hjwp/minimal-django-custom-user-model/commit/377a83a9c995b2346b79458dcb5d48c0caed90df

The user looks like this:


class User(models.Model):
    email = models.EmailField(primary_key=True)
    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ()



But unfortunately, if I every put one through the django login function 
(from contrib.auth), he barfs:


  File 
"/usr/local/lib/python3.3/dist-packages/django/contrib/auth/__init__.py", 
line 97, in login
    user_logged_in.send(sender=user.__class__, request=request, user=user)
  File 
"/usr/local/lib/python3.3/dist-packages/django/dispatch/dispatcher.py", 
line 170, in send
    response = receiver(signal=self, sender=sender, **named)
  File 
"/usr/local/lib/python3.3/dist-packages/django/contrib/auth/models.py", 
line 31, in update_last_login
    user.save(update_fields=['last_login'])
  File "/usr/local/lib/python3.3/dist-packages/django/db/models/base.py", 
line 526, in save
    % ', '.join(non_model_fields))
ValueError: The following fields do not exist in this model or are m2m 
fields: last_login

If you checkout the repo, I've written a test that reproduces same.


I don't care about last_login!  Can this be circumvented?  Should that 
signal be optional, or gracefully handle the case where the user model has 
no last_login field?  Should I log this as a bug?

HP

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ae58a9ef-a086-474d-9374-13a97ac176de%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to