python - Convert DateField to unix timestamp in Django -


how can convert datefield() value unit timestamp representation in django?

as datefield() returns native python datetime.date instance, https://docs.python.org/2/library/datetime.html, same converting datetime.date object unix timestamp integer.. such as:

import time import django.models models  date = models.datefield() unix_timestamp = int(time.mktime(date.timetuple())) 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -