1👍
✅
You can use the timeuntil()
function which is used for the timeuntil
template filter:
from django.utils.timesince import timeuntil
def expiration(self):
return timeuntil(self.date_offered)
0👍
I used this method to determine if my user was an adult (i.e., at least 18 years old). You should be able to manipulate it for your needs.
from datetime import date
def set_adult(self):
today = date.today()
age = today.year - self.date_of_birth.year - ((today.month, today.day) < (self.date_of_birth.month, self.date_of_birth.day))
if age >= 18:
self.adult = True
else:
self.adult = False
👤erip
- [Answer]-Django mutiupload not working
- [Answer]-Django Social Auth redirect to url with Port number
- [Answer]-Need to create a user application in python-Django framework where based on input data will insert or update in the database
- [Answer]-I return a dict from the views.py to the templates as a value of a radio, but it looks like the "value" would cut down the text
- [Answer]-Phant : No 'Access-Control-Allow-Origin'
Source:stackexchange.com