I'm happy to announce the release of django-service-urls package, an evolution of dj-database-url which can handle CACHES and EMAIL_BACKEND setting other than DATABASES.
--
Urls
pypi and docs: https://pypi.org/project/django-service-urls/
main repo (bitbucket): https://bitbucket.org/rsalmaso/django-service-urls/
github mirror: https://github.com/rsalmaso/django-service-urls
gitlab mirror: https://gitlab.com/rsalmaso/django-service-urls
(I accept patches from every repository)
Install
$ python3 -m pip install django-service-urls
In your settings.py file add at the end one handler for each setting you use
import service_urls
DATABASES = service_urls.db.parse(DATABASES)
CACHES = service_urls.cache.parse(CACHES)
if service_urls.email.validate(EMAIL_BACKEND):
for k, v in service_urls.email.parse(EMAIL_BACKEND).items():
setting = 'EMAIL_' + ('BACKEND' if k == 'ENGINE' else k)
globals()[setting] = v
CACHES = service_urls.cache.parse(CACHES)
if service_urls.email.validate(EMAIL_BACKEND):
for k, v in service_urls.email.parse(EMAIL_BACKEND).items():
setting = 'EMAIL_' + ('BACKEND' if k == 'ENGINE' else k)
globals()[setting] = v
Usage
Configure your setting (see docs for better example).
Configure your setting (see docs for better example).
DATABASES = {
'default': os.environ.get('DATABASE_DEFAULT', 'postgres://myuser:mypasswd@localhost:5432/mydb'),
}
CACHES = {
'default': os.environ.get('CACHE_DEFAULT', ''memcached://127.0.0.1:11211'),
}
EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND', 'smtp://localhost:25')
'default': os.environ.get('DATABASE_DEFAULT', 'postgres://myuser:mypasswd@localhost:5432/mydb'),
}
CACHES = {
'default': os.environ.get('CACHE_DEFAULT', ''memcached://127.0.0.1:11211'),
}
EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND', 'smtp://localhost:25')
| Raffaele Salmaso
| https://salmaso.org
| https://bitbucket.org/rsalmaso
| https://github.com/rsalmaso
| https://salmaso.org
| https://bitbucket.org/rsalmaso
| https://github.com/rsalmaso
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABgH4JuDanE0KegwNBmZ1qq1QmeQHn1-%3DLGqNtu2mHXz%3DLW7uQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment