Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/references/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ See https://djp.readthedocs.io/ for more information.
You can set the `DJP_PLUGINS_DIR` environment variable to point to a directory which contains *.py files implementing plugins. Good for development and when you do not want to publish the plugin on PyPI.

Since DJP allow a plugin to override any setting you can tell Hypha to look for templates in a directory inside your plugin. This allows the plugin to override any template in Hypha.

## URL ordering

URLs contributed through the DJP `urlpatterns()` hook are added to the root urlconf **after** Hypha's own routes but **before** Wagtail's page-serving catch-all (`path("", include(wagtail_urls))`). This means:

- A plugin **cannot** shadow a core Hypha URL (e.g. `apply/`, `admin/`, `account/`) — core routes are matched first.
- A plugin URL **is** reachable even when it is slug-shaped (e.g. `account/country/`). Wagtail's catch-all would otherwise match any such path and return a 404 (*"The current path … matched the last one."*), so plugin URLs are deliberately placed ahead of it.
- A plugin URL takes precedence over a Wagtail page at the same path.

Prefer the `urlpatterns()` hook for adding routes. Only manipulate the root urlconf directly (e.g. from `AppConfig.ready()`) if you need finer control than the hook provides.
7 changes: 4 additions & 3 deletions hypha/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@
),
]

# Load urls from any djp plugins.
urlpatterns += djp.urlpatterns()

# Need to be last.
urlpatterns += [
path("", include(wagtail_urls)),
]

# Load urls from any djp plugins.
urlpatterns += djp.urlpatterns()

if settings.DEBUG:
import debug_toolbar

Expand Down