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'] |