Your SlideShare is downloading. ×
  • Like
Django settings with django-configurations
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Django settings with django-configurations

  • 10,233 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
10,233
On SlideShare
0
From Embeds
0
Number of Embeds
13

Actions

Shares
Downloads
16
Comments
0
Likes
5

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

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