Hi all,
I have a very simple Profile class:
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
location = models.CharField(max_length=30, blank=True)
birth_date = models.DateTimeField(null=True, blank=True)
date_activation = models.DateTimeField(null=True, blank=True)
I want to set date_activation = datetime.now the first time the user login.
I tried using "user_logged_id" signal, without success:
@receiver(user_logged_in, sender=User)
def user_logged_in_callback(sender, user, request, **kwargs):
Profile.objects.filter(get_user(request)).update(date_activation=datetime.now)
Testing it I get this errore message below.
Any help or suggestions would be greatly appreciated!
TypeError at /admin/login/
int() argument must be a string, a bytes-like object or a number, not
'ModelBase'
Request Method: POST
Request URL: http://localhost:4000/admin/login/?next=/admin/
Django Version: 1.11.16
Exception Type: TypeError
Exception Value:
int() argument must be a string, a bytes-like object or a number, not
'ModelBase'
Exception Location:
/usr/local/lib/python3.6/site-packages/django/db/models/fields/__init__.py
in get_prep_value, line 966
Python Executable: /usr/sbin/uwsgi
Python Version: 3.6.5
Python Path:
['.',
'',
'/code',
'/usr/local/lib/python3.6/site-packages',
'/usr/lib/python3.6/site-packages',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload']
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" 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 https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/fd7793b7-305a-4916-bae8-e8de687be346%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.