Skip to main content

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.


"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?


  1. pip install django_tree_view

  2. In your 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 = [

    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.

  3. Optionally, add the full path to your tree view root to the DIRS option of your DjangoTemplates backend:

            '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



If no file, or module.NO_MATCH = True, then NoMatch instead of 405 When DEBUG and reloading, reload empty modules

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-tree-view, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_tree_view-0.0.1-py3-none-any.whl (9.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django_tree_view-0.0.1.tar.gz (6.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page