1
我正在擴展用戶配置文件並添加了如下所示的last_ip字段。當用戶登錄到當前IP時,如何更新此字段?如果它很重要,我正在使用allauth。如何在django中獲取最後一次登錄ip並保存到GenericIPAddressField?
class UserProfile(models.Model):
user = models.OneToOneField(User)
last_ip = models.GenericIPAddressField(protocol='IPv4', verbose_name="Last Login IP")
location = models.CharField(max_length=50, blank=True)