1๐
โ
You can do it in the view (not in the template).
- Create 2 variables (1 corresponding to now, 1 corresponding to now+1month)
- Pass them to your template
In views.py
from datetime import datetime
def yourView(request):
now_date = datetime.now()
now_date_plus_1m = ... # I let you search how to to this :)
return render_to_response('your_template.html',
{
'now_date': now_date,
'now_date_plus_1m': now_date_plus_1m
},
RequestContext(request)
)
In your template file:
.datetimepicker({value:'{{ now_date|date:"Y-m-d H:i" }}',step:10});
.datetimepicker({value:'{{ now_date_plus_1m|date:"Y-m-d H:i" }}',step:10});
๐คDavid Dahan
1๐
The django template system is meant to express presentation, not program logic this why you should do your logic at the view level
- [Answered ]-After execute makemigrations some items are missing in the result
- [Answered ]-List sent over AJAX and compared to seemingly identical list in Django returns false
- [Answered ]-How do I properly nest serializers in Django REST Framework?
Source:stackexchange.com