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 details)
Built Distribution
File details
Details for the file django_hookup-0.0.2.tar.gz
.
File metadata
- Download URL: django_hookup-0.0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b43473ebda61c5ce76f11ce9538c25ea7337a3f41e67f5c857ecf11ac7ab82b |
|
MD5 | fcb11f5bedc5b6fd0daaec51d6350163 |
|
BLAKE2b-256 | 361d4f2380c8b26dcbd667a50bf9ff8485905324eb2cd3e6ddb78646f4772d5a |
File details
Details for the file django_hookup-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: django_hookup-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00cf86bc414db9108e321ab7d783b2f4706544f9a940535d590e71f41d8e6658 |
|
MD5 | 8e1e248c31d4fd3904607d6866dcd0e2 |
|
BLAKE2b-256 | 61ad2211e77a8577d02c210da4d84b0f271572d06c2edb59226020f1725d1ea5 |