Hi all,

I'm trying to update the field "date_activation" the first time a user log 
in.

This is the error I get when i try to run the code below

*TypeError at /admin/login/ int() argument must be a string, a bytes-like 
object or a number, not 'ModelBase'*

Any help would be really appreciated!





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)


@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        Profile.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
    instance.profile.save()

@receiver(user_logged_in, sender=User)
def user_logged_in_callback(sender, user, request, **kwargs):
    Profile.objects.filter(user=User).update(date_activation=datetime.now)



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/237c6adf-1d2c-4ce7-b8d6-60a7d827833a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to