mini_render_to_response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def mini_render_to_response(template, context, context_instance, try_mobile = True, *args, **kwargs):
    render = None
    if try_mobile and context_instance['request'].GET.has_key('mini'):
        try:
            file, ext = template.split('.')
        except ValueError: pass
        else:
            mini_template = file + '_mini.' + ext
            try:
                render = render_to_response(mini_template, context, context_instance=context_instance, *args, **kwargs)
            except TemplateDoesNotExist: pass
    
    if not render:
        render = render_to_response(template, context, context_instance=context_instance, *args, **kwargs)
    
    return render

More like this

  1. Detect iPhone & Switch Template via render_to_response by bryanhelmig 3 years ago
  2. Mobilize your Django site by stevena0 4 years, 2 months ago
  3. Simple Mobile Support by bahoo 2 years, 8 months ago
  4. another render_to_response wrapper by ro60 5 years, 5 months ago
  5. render_with decorator by tobias 4 years, 9 months ago

Comments

(Forgotten your password?)