I'd like to deliver special versions of my django site for different (mobile-)browser. What are possible solutions to do this?
+1
A:
In your view, do smthg like this
def map(request, options=None, longitude=None, latitude = None):
if 'iPhone' in request.META["HTTP_USER_AGENT"]:
user_agent = 'iPhone'
elif 'MSIE' in request.META["HTTP_USER_AGENT"]:
user_agent ='MSIE'
else: user_agent=''
print user_agent
return render_to_response('map/map.html',
{
'user_agent': user_agent
})
and in your template
{% ifnotequal user_agent "iPhone" %}
{% ifequal user_agent "MSIE" %}
{% include 'map/map_ie.html' %}
{% else %}
{% include 'map/map_default.html' %}
{% endifequal %}
{% else %}
{% include 'map/map_iphone.html' %}
{% endifnotequal %}
vikingosegundo
2009-05-29 14:48:50
I'd like to vote up... but i yet can't
2009-05-29 14:50:31
doesn't matter :D Welcome to SO
vikingosegundo
2009-05-29 14:55:58
+2
A:
Seems like this has already been answered here: http://stackoverflow.com/questions/164427/change-django-templates-based-on-user-agent
Matthew Christensen
2009-05-29 14:49:46