how to know which client in template

1 view
Skip to first unread message

yonatan braude

unread,
Jan 19, 2012, 5:10:43 AM1/19/12
to pywe...@googlegroups.com
working on the django-cms video plugin... I want to {% include %}  template based on the client. so I want to know what client is...

I did this:

in: '/cms/plugins/video/cms_plugins.py'

'''
    def render(self, context, instance, placeholder):
        
        cntx = context.dicts[0]
        rqcntx = cntx.dicts[0]
        wsgirqst = rqcntx.dicts[4]['request']
        mta = wsgirqst.META
        client = mta['HTTP_USER_AGENT']


        context.update({
            'object': instance,
            'placeholder':placeholder,
            'client': client
        })
        return context
'''

I guess this is not the right way? :)

yonatan

Alex Arshavski

unread,
Jan 19, 2012, 5:20:55 AM1/19/12
to pywe...@googlegroups.com
No. It's not the only way. You can do something like:

{% if "Mozilla" in request.META.HTTP_USER_AGENT %}
    Do something...
{% endif %}

in the template.

Regards, Alex A.

--
You received this message because you are subscribed to the Google Groups "PyWeb-IL" group.
To post to this group, send email to pywe...@googlegroups.com.
To unsubscribe from this group, send email to pyweb-il+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyweb-il?hl=en.

Reply all
Reply to author
Forward
0 new messages