[ANN] django-service-urls 1.1.0

15 views
Skip to first unread message

Raffaele Salmaso

unread,
Jan 19, 2019, 4:11:16 AM1/19/19
to django...@googlegroups.com
I'm happy to announce the 1.1.0 release of django-service-urls package, an evolution of dj-database-url which can handle CACHES and EMAIL_BACKEND setting other than DATABASES.

News
Simplified installation: instead of modifying the setting file (possibility that is always available) just add import service_urls.patch in your manage.py/wsgi.py files.


Install
$ python3 -m pip install django-service-urls


Add import service_urls.patch to manage.py and wsgi.py

manage.py:
#!/usr/bin/env python 
"""Django's command-line utility for administrative tasks.""" 
import os 
import sys 
import service_urls.patch

def main(): 
   os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings') 
   try: 
       from django.core.management import execute_from_command_line 
   except ImportError as exc: 
       raise ImportError( 
           "Couldn't import Django. Are you sure it's installed and " 
           "available on your PYTHONPATH environment variable? Did you " 
           "forget to activate a virtual environment?" 
       ) from exc 
   execute_from_command_line(sys.argv) 


if __name__ == '__main__': 
   main()


wsgi.py:
import os
import service_urls.patch
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings')
application = get_wsgi_application()

Usage

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')


--
Reply all
Reply to author
Forward
0 new messages