Main idea from Julien Phalip
Compatible with django 1.11+
Checks is the view function decorated or not
Parameters: view – view function Return type: bool
returns callable instance of view from view path :param view_path: view path, like ‘django.contrib.auth.views.login’ :return: a callable instance of view, in this example login
Checks is the request path is listed in PUBLIC_PATHS, so it is not login required.
Parameters: path (string) – the request path Returns: true if view was listed in PUBLIC_PATHS. Return type: bool
Checks is the view is listed in PUBLIC_VIEWS, so it is not login required.
Parameters: view (callable) – the view Returns: true if view was listed in PUBLIC_VIEWS. Return type: bool
process_view(request, view_func, view_args, view_kwargs)¶
checks if this view is not in excluded views (by PUBLIC_VIEWS, PUBLIC_PATHS or login_not_required decorator), adds login_required decorator for view, otherwise run the view it self.
read the documentation at djangoproject
- request (HttpRequest) – this will be passed to next process_view and finally will be passed to view.
- view_func (callable) – the view function
- view_args – the arguments that will be passed to view
- view_kwargs – the keyword arguments that will be passed to view
None in order to continue processing process_view in middleware chain or ` HttpResponse` for braking middleware chain.
Decorator which marks the given view as public (not login required).
This decorator adds a read only property `` LOGIN_NOT_REQUIRED`` to the view, and if it’s value be
True, the middleware will not force for login.
If you combine this with a
login_requireddecorator, your view will be login required.