Django settings with django-configurations
Upcoming SlideShare
Loading in...5
×
 

Django settings with django-configurations

on

  • 5,478 views

 

Statistics

Views

Total Views
5,478
Views on SlideShare
5,173
Embed Views
305

Actions

Likes
4
Downloads
11
Comments
0

9 Embeds 305

https://twitter.com 160
http://syssr.org 99
http://www.slideee.com 25
http://lanyrd.com 10
http://localhost 6
http://prlog.ru 2
http://eventifier.co 1
https://tweetdeck.twitter.com 1
https://www.google.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Django settings with django-configurations Django settings with django-configurations Presentation Transcript

  • „ Django settings with django-configurations
  • Bridge between Django’s module settings system and class based configurations. django-configurations
  • # mysite/settings.py ! from configurations import Configuration ! class Dev(Configuration): DEBUG = True django-configurations View slide
  • export DJANGO_SETTINGS_MODULE= 'mysite.settings' ! export DJANGO_CONFIGURATION= 'Dev' django-configurations View slide
  • python manage.py runserver --settings=mysite.settings --configuration=Dev django-configurations
  • Applies the class content to the containing module before Django reads it. django-configurations
  • It’s a hack. But it uses PEP 302. django-configurations
  • # mysite/settings.py ! from configurations import Configuration ! ! class Dev(Configuration): ! @property! def LANGUAGES(self):! return (Configuration.LANGUAGES + (('tlh', 'Klingon'),))! django-configurations
  • # mysite/settings.py ! from configurations import Configuration ! ! class PageCaching(object): USE_ETAGS = True ! class Prod(Configuration, PageCaching): DEBUG = False django-configurations
  • • Mixins • Facades • Factories • Adapters ! • Setup hooks • Values What else?
  • Reduces the amount of validation and setup code and lookup the process environment of your software (os.environ). ! Follows the Twelve-Factor methodology. Values
  • Value BooleanValue IntegerValue FloatValue DecimalValue ListValue TupleValue SetValue DictValue EmailValue URLValue IPValue RegexValue PathValue DatabaseURLValue CacheURLValue EmailURLValue SearchURLValue BackendsValue SecretValue ! and more.. Values
  • # mysite/settings.py ! from configurations import (values, Configuration) ! ! class MySiteBase(Configuration): DEBUG = values.BooleanValue(True) TEMPLATE_DEBUG = values.BooleanValue(DEBUG) Values
  • export DJANGO_DEBUG=true Values
  • # mysite/settings.py ! from configurations import (values, Configuration) ! ! class MySiteBase(Configuration): DATABASES = values.DatabaseURLValue( 'sqlite://') Values
  • export DATABASE_URL= 'postgres://user:pass@localhost/mydb' Values
  • django-configurations.rtfd.org ! @jezdez