Wednesday, February 2, 2011

Re: Using custom / Extending default Request Object

Thanks that's gr8!

On 2 Lut, 21:52, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Wednesday, February 2, 2011 8:38:58 PM UTC, Tereska wrote:
>
> > My RequestObject must contain information about user device (mobile,
> > tablets etc) with device capatibilites (resolution, video codecs
> > etc) .
> > It's a data collection not simple string. Then I want use it in views
> > and templates.
>
> So, simply attach your information as an attribute of the standard request
> object. No need to replace it. You probably want to do this in a middleware.
>
>     class DeviceInfoMiddleware(object):
>         def process_request(self, request):
>             request.device_info = {'resolution': '800x600', 'codecs':
> ['H264', 'WebM']}
>
> --
> DR.

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate