Reputation: 201
I have one trouble, in html file i'm need to use date field, and filed him date from django. Example my first field (correctly)
.datetimepicker({value:'{% now "Y-m-d H:i" %}',step:10});
In the next field, i must set mouth + 1, ho i can do this?
For example :
.datetimepicker({value:'{% now "Y-(m+1)-d H:i" %}',step:10});
Thanks.
Upvotes: 1
Views: 68
Reputation: 2750
The django template system is meant to express presentation, not program logic this why you should do your logic at the view level
Upvotes: 1
Reputation: 11162
You can do it in the view (not in the 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});
Upvotes: 1