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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Django settings with django-configurations

29,050

Published on

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
29,050
On Slideshare
0
From Embeds
0
Number of Embeds
17
Actions
Shares
0
Downloads
20
Comments
0
Likes
7
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

×