Set browser/os requirement

Hello all

I’m new to django programming, not python, and could do with a hand.

I am attempting to make a website exclusive to a certain device. I have created a disallow page accessible by the ‘/disallow/’. How do I go about running os/browser checks that then redirect in the event the os/browser is not on the verified list.

I know the information I am wanting to check will be in the request and I can use

request.META['HTTP_USER_AGENT']

However where do I write any logic required and how could I apply this to any page the user trys to access.

Any help would really be appreciated
Ed

If you want it to apply to every (or almost every) request, you can create custom middleware that can examine that field before the request is dispatched to the proper view - redirecting it if necessary.

Ken

1 Like