I have created an expiredate
field which is generated automatically based on the registerdate
field
I've tried a regular query just like i would use for any field (it is mentioned below)
this is the model:
class UserProfile(models.Model):
course = models.ForeignKey(Category, on_delete=models.DO_NOTHING)
phonenumber = models.CharField(max_length=50)
registerdate = models.DateTimeField()
expiredate = timezone.now().date() + timedelta(days= 70)
user = models.OneToOneField(User, on_delete = models.CASCADE)
def __str__(self):
return "{}" .format(self.user)
and this is the query i'm trying to use:
expire = UserProfile.objects.values('expiredate')
I simply want to select the expiredate
and use it on my views.py
function but the query generates an error:
'Cannot resolve keyword 'expiredate' into field. Choices are: course, course_id, id, phonenumber, registerdate, user, user_id'