CRUDLFA+ introduces an MVC-ish pattern, as the Router class is meant to sit between a Model class and its set of View. Your views will have to inherit from Route to work in Router.views. This structural decision made for you by CRUDLFA+ was not exactly designed: it’s an open source rewrite of a module that was ordered in a proprietary project.
The mixin for Views that will make it compatible with Router.
False by default, it makes the default has_perm() implementation require Django permission.
Args that should be passed to reverse() along with Route.urlfullname.
Absolute url to the view, relying on Route.urlfullname and Route.urlargs.
You will be able to check if a user has access to a view with a given object for example as such:
crudlfap.site[YourModel]['detail'].clone( request=request, object=obj, ).has_perm()
If you want to open a View to all, set authenticate=False, examples:
class YourDetailView(DetailView): authenticate = False class YourRouter(Router): views = [ YourDetailView, ListView.clone(authenticate=False), # example with clone ]
Without authenticate=False, the default has_perm() implementation requires the request user to have the permission corresponding to the permission_fullcode attribute.
To create the permission with permission_fullcode, you can browse in your CRUDLFA+ site and navigate to URL list view, for each URL you have link in the menu called “authorized” that lets you select which groups have this permission: it will auto-create the permission in the database if necessary.
dispatch(request, *args, **kwargs)¶
This will run has_perm prior to super().dispatch().
Return the codename attribute for the view Permission.
Return a string with the app name, permission_shortcode and model name.
Return the middle part for the view permission.
Returns the urlname by default.
Return the URL for this view given its current state. Given that the
reverse()method is a class method, this should allow things like:
url = YourView(object=your_object).url
Return args for reversing this view url from self. See
Checks for user permission.
Reverse a url to this view with the given args.
Base autocalculations for views.
The view’s app name.
The view’s model if any.
The path for the url path definition.
The view label, serves as key in a Router.views.
The Django URL path() instance, for inclusion in url lists.
The full name to reverse the URL, with namespaces if any.
The default model field that will be use to match in the URL. It can be pk, or name, slug …
Return the model’s app_name or None.
Return a readable label for this view.
Strips View and Route from class name, also removes the model class name if it finds it: for YourModelUpdateView this returns update.
Return the router’s model or None.
Return the router urlfield if any, else guess_urlfield()
Return the url name eventually with router and site namespaces.
Return a string that can be used as url name.
Return the urlname.
Return the Django URL object to include in a urlpatterns.