1👍
✅
Well on the first instance I can see two problems in your code
1.
I don’t understand the meaning of this:
Paid.objects.get(expire='expire')
You are trying to get the Paid object on the basis of user and find if Paid object is expired hence something like this is more appropriate
Paid.objects.get(user=request.user).expire >= d.strptime("%Y-%m-%d"):
The other problem is the same as karthikr has mentioned
expire is a datefield not datetime and hence you get a ValidationError the datatype mentioned is a date where data type being sent is datetime
Since the error mentions it expects datetime in ‘YYYY-MM-DD’
Try something like this
>>> datetime.datetime.now().date() + datetime.timedelta(days=29)
datetime.date(2013, 7, 6)
>>> str(datetime.datetime.now().date() + datetime.timedelta(days=29))
'2013-07-06'
Try to send this string in YYYY-MM_DD
1👍
The line
expire=datetime.datetime.now()+ datetime.timedelta(days=29)
is providing a date and time value, you just want the date – so use .date()
ie;
expire = datetime.datetime.now().date() + datetime.timedelta(days=29)
Source:stackexchange.com