Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import os
  2. from datetime import datetime
  3.  
  4. DATABASES = {
  5. 'default': {
  6. # the usual lines ...
  7. TEST_NAME: '{user}_{epoch_ts}_awesome_app'.format(
  8. user=os.environ.get('USER', os.environ['LOGNAME']),
  9. # This gives the number of seconds since the UNIX epoch
  10. epoch_ts=int((datetime.utcnow() - datetime.utcfromtimestamp(0)).total_seconds())
  11. ),
  12. # etc
  13. }
  14. }
  15.  
  16. from django.conf import settings
  17.  
  18. # This is bad because settings might still be in the process of being
  19. # configured at this stage.
  20. blah = settings.BLAH
  21.  
  22. def some_view():
  23. # This is okay because by the time views are called by Django,
  24. # the settings are supposed to be all configured.
  25. blah = settings.BLAH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement