Simple Django Hooks
Project description
Django Hookup
Simple Django Hooks.
Install:
pip install django_hookup
Register function:
# myapp.hooks.py
import django_hookup
@django_hookup.register("register_foobar", order=1)
def say_foo(text):
"""Concat foo and given text"""
return "foo:%s " % text
@django_hookup.register("register_foobar", order=0)
def say_bar(text):
"""Concat bar and given text"""
return "bar:%s " % text
Calling hooks
# myapp.somewhere.py
import django_hookup
hooks = django_hookup.get_hooks("register_foobar")
text = ""
for func in hooks:
text += func(func.__name__)
print(text)
Hooks Admin (Optional)
Add django_hookup in settings.py
# settings.py
INSTALLED_APPS = [
"example.app",
"django_hookup",
#
'django.contrib.admin',
...
]
Add django_hookup.url
# settings.py
urlpatterns = [
path("admin/hooks/", include("django_hookup.urls")),
path("admin/", admin.site.urls),
]
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
django_hookup-0.0.2.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for django_hookup-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00cf86bc414db9108e321ab7d783b2f4706544f9a940535d590e71f41d8e6658 |
|
MD5 | 8e1e248c31d4fd3904607d6866dcd0e2 |
|
BLAKE2b-256 | 61ad2211e77a8577d02c210da4d84b0f271572d06c2edb59226020f1725d1ea5 |