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 convenientuser_passes_test
decorator.
Comments
Post a Comment