I think we should change how view trees are "installed". Our path resolver no longer matches when the "path directory" contains no view_tree_node.py file. When DEBUG and reloading, reload empty modules (not sure, but this might already be done). You may want to check out the documentation for django_referer_csrf, and use their middleware in place of Django's, but this is not required. We use utilities from django_referer_csrf. The CSRF protection we use is not Django's default CSRF protection. Our view uses Django's csrf_exempt decorator, and selectively applies its own CSRF protection.Īny view tree node can opt-out of CSRF protection by setting CSRF_EXEMPT=True at the module level. This will allow you to place page-specific templates inside the same directory which holds the view code for that url. Optionally, add the full path to your view tree to the DIRS option of your DjangoTemplates backend: TEMPLATES = Note: you can use include('some_path/', ) if you want a url prefix. make_tree_view() returns an object which dynamically resolves urls, matching them whenever there is a corresponding directory (with a view_tree_node.py module) inside of your view tree. Note: we're not using django's path() here, and we didn't specify a url regex. In your urls.py file, add in a call to make_tree_view, passing in the python package name (dotted python path) of your view tree: from django_tree_view import make_tree_view urlpatterns = "Tree View" refers the actual view function we've created, which processes a request according to code you write inside your "view tree". Organize your view code and templates and in a directory structure, and automatically generate urls for them.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |