1π
β
If you donβt want to use the decorator approach, your best bet is to write a middleware that checks if request.user
is activated or not, then redirect (to a page where they can reactivate their account preferably) when necessary.
Roughly youβd want something like this:
from django.shortcuts import redirect
class DeactivatedRedirectMiddleware(object):
def process_request(self, request):
if request.user and not request.user.is_anonymous():
if request.user.deactivated and request.get_full_path() != '/some/url/':
# redirect here
return redirect('/some/url/')
# ...
π€K Z
0π
You can use decorator function to check if user is activated and redirect him.
How to write a custom decorator in django?
π€szaman
- [Answer]-Django queries based on amount of many to many relationships
- [Answer]-Django: Problems uploading files with AJAX
- [Answer]-How can implement foreign key in admin and model
0π
Use a view decorator.
Good article about it: http://passingcuriosity.com/2009/writing-view-decorators-for-django/
π€Ponytech
Source:stackexchange.com