Skip to content

Commit dec8d27

Browse files
authored
Implement DJP: Django Plugins. (#4201)
Read up on DJP at https://djp.readthedocs.io/
1 parent 02398cd commit dec8d27

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

docs/references/plugins.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Hypha implements DJP: Django Plugins. A plugin system for Django.
2+
3+
See https://djp.readthedocs.io/ for more information.
4+
5+
## Some tips
6+
7+
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.
8+
9+
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.

hypha/settings/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66

77
import dj_database_url
8+
import djp
89
from environs import Env
910

1011
from .django import * # noqa
@@ -623,3 +624,6 @@
623624
debug=SENTRY_DEBUG,
624625
integrations=[DjangoIntegration()],
625626
)
627+
628+
# Load settings from any djp plugins.
629+
djp.settings(globals())

hypha/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import djp
12
from django.conf import settings
23
from django.contrib import admin
34
from django.urls import include, path, re_path
@@ -104,6 +105,8 @@
104105
path("", include(wagtail_urls)),
105106
]
106107

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

108111
if settings.DEBUG:
109112
import debug_toolbar

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ django-web-components==0.2.0
3535
django==4.2.16
3636
djangorestframework-api-key==3.0.0
3737
djangorestframework==3.15.2
38+
djp==0.3.1
3839
drf-nested-routers==0.93.5
3940
environs==11.0.0
4041
gunicorn==22.0.0

0 commit comments

Comments
 (0)