1👍
✅
I would presume you would pass the params in when rendering the template in your view, like so:
def yourview(request, month, year):
return render_to_string("template.html", {
"month": month,
"year": year,
})
and then change get_calendar
accordingly:
{% get_calendar for month year as calendar %}
1👍
I want to present, how I fixed my problem, for others who might have similar problems:
With the help of the user fish2000, I managed my question like this:
My defined view:
# Create your views here.
from django.shortcuts import render_to_response
from django.template import RequestContext
import datetime
def calender_view(request, template_name="custom_template_calender_tag.html"):
d = datetime.date.today()
recent_month = d.month
recent_year = d.year
return render_to_response(template_name, locals(),context_instance=RequestContext(request))
and then changed get_calendar
from
{% get_calendar for 10 2010 as calendar %}
to
{% get_calendar for recent_month recent_year as calendar %}
to provide and render the recent month and year dynamically in my template custom_template_calender_tag.html
.
- [Answered ]-Django request data as parameters
- [Answered ]-How to get a JSON response from a POST form using Django
- [Answered ]-Delete record in Django db with ajax
- [Answered ]-Django pagination while objects are being added
- [Answered ]-Does Django-1.5.1 still support the mod_python-3.3.1?
Source:stackexchange.com