Organize your code and templates in a natural directory structure
Project description
Django Tree View
Organize your view code and templates and in a directory structure, and automatically generate urls for them.
Terminology
"Tree View" refers the actual view function we've created, which processes a request according to code you write inside your "view tree".
TODO - rename to django_view_tree?
Installation
-
pip install django_tree_view
-
In your urls.py file, add in a call to
make_tree_view
, passing in the python package name (dotted python path) of your "tree view root":from django_tree_view import make_tree_view urlpatterns = [ make_tree_view('my_view_tree'), ]
Note - we're not using django's path() here, and we didn't specify a url regex. make_tree_view() returns an object which dynamically resolves urls, matching them whenever there is a corresponding directory inside of your tree view root.
TODO - document that you can use include('some_path/', [make_tree_view()]) if you want a url prefix.
-
Optionally, add the full path to your tree view root to the
DIRS
option of yourDjangoTemplates
backend:TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'my_view_tree')], ... }, ]
This will allow you to place page-specific templates inside the same directory which holds the view code for that url.
Organizing Your View Tree
TODO
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_tree_view-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d6ac6222d335643d40a0ba4cbc1c4096da28d85e4b5195f7a3822087d26eda3 |
|
MD5 | 0fc6d38740e368e229cbacd03b93b56a |
|
BLAKE2b-256 | b8ad318d3dd2a2c02b001c486a2b6b08db68160b2f474e9e07d13521a77a9cb1 |