I am trying to create a Django TemplateLoader, but I do not want to see it as 'current' or existing context or 'see'
Many thanks
which << / P>
You have the place to make a decision about, you have access to the request, and you can dynamically build the template name based on the conditions you like. EG,
def my_view (Request, ...): ... template_name = 'template.html' if is_mobile (request): template_name = 'mobile_' + template_name template = get_template (template_name)) reference = RequestContext (request, {...}) Return HttpResponse (template.render (context))
Where you provide is_mobile ()
, a method and template that would be better to provide a method , And gives a properly revised return (so that you can once, by changing that argument into symbolic words, instead of scattering in many scenes) .
Leverage, which takes a list of candidate's template names, returns the template for the first to find it.
Comments
Post a Comment