python - Django decorator to redirect based on user-type -


currently in django app, have 2 kind of users, usertypea , usertypeb.

at point, redirect both of types /usercheck/ has function check type of user, , redirect them accordingly. working out pretty well.

however, curiosity, if write decorator put ?

one place can think of settings.py decorator output different login_redirect_url based on user type.

it learning. current implementation working out pretty far.

thanks lot.

settings.py meant global static configuration data, not try dynamically changing settings. there many other places in django login url can set explicitly.

i'm not entirely clear on want do, sounds user_passes_test decorator you're after. the docs:

limiting access logged-in users pass test: simple way run test on request.user in view directly.... shortcut, can use convenient user_passes_test decorator.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -