- Author:
- aisbaa
- Posted:
- October 5, 2011
- Language:
- Python
- Version:
- Not specified
- Score:
- 2 (after 2 ratings)
Django signals can live anywhere you like. I like them in app/signals.py file. This snippet imports signal modules from all installed apps.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import logging
from importlib import import_module
from django.conf import settings
print logging, logging.__name__
logger = logging.getLogger(__name__)
signal_modules = {}
for app in settings.INSTALLED_APPS:
signals_module = '%s.signals' % app
try:
signal_modules[app] = import_module(signals_module)
except ImportError as e:
logger.warning(
'failed to import "%s", reason: %s' % (signals_module, str(e)))
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 10 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
- Help text hyperlinks by sa2812 1 year, 6 months ago
Comments
sry left prin by mistake XD,, can edit this snippet ?
#
Please login first before commenting.