from django.shortcuts import render_to_response as render_to_response_pre def render_to_response(template, context): ''' If the exisiting view uses a template named foo.html, any iPhone will trigger the template named foo-iphone.html. ''' if 'HTTP_USER_AGENT' in context['request'].META: if 'iphone' in context['request'].META['HTTP_USER_AGENT'].lower(): template = template.rstrip('.html') template += '-iphone.html' return render_to_response_pre(template, context)