Django-classbasedsettings.

Ŭ·¡½º¸¦ »ç¿ëÇÏ¿© ¼³Á¤À» Á¤ÀÇÇÕ´Ï´Ù.
Áö±Ý ´Ù¿î·Îµå

Django-classbasedsettings. ¼øÀ§ ¹× ¿ä¾à

±¤°í

  • Rating:
  • ƯÇã:
  • BSD License
  • °¡°Ý:
  • FREE
  • °Ô½ÃÀÚ À̸§:
  • Matthew Tretter
  • °Ô½ÃÀÚ À¥»çÀÌÆ®:
  • http://github.com/matthewwithanm/

Django-classbasedsettings. ű×


Django-classbasedsettings. ¼³¸í

Django-ClassBaseDsettings´Â ¸ðµâ ´ë½Å Ŭ·¡½º¸¦ »ç¿ëÇÏ¿© Django ÇÁ·ÎÁ§Æ®ÀÇ ¼³Á¤À» Á¤ÀÇ ÇÒ ¼öÀÖ´Â Django ¾ÛÀÔ´Ï´Ù. ´Ù¸¥ °Íµé Áß »ó¼Ó ¹× °è»ê µÈ ¼Ó¼ºÀ» »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ¼³Ä¡ÇÏ´Â °¡Àå ½¬¿î ¹æ¹ýÀº PIP¸¦ »ç¿ëÇÏ¿© ÇÈóÀÔ´Ï´Ù. Django-ClassBaseDetingSettingShowever¸¦ »ç¿ëÇÏ¿© "CBSETTINGS"Æú´õ¸¦ PythonPath.setUpThe À§Ä¡¿¡ ¹æ¿ï ¼ö ÀÖ½À´Ï´Ù. Django_Settings_ModuleÀ» ¼³Á¤Çϸé CBSetTINGS.CONFIGURE¿¡ ÀüÈ­ÇؾßÇÕ´Ï´Ù. µû¶ó¼­ manage.py´Â ´ÙÀ½°ú °°ÀÌ º¸ÀÔ´Ï´Ù. #! / usr / bin / env pythonimport sysimport cbsettingsif __name__ == "__main__": cbsettings.configure ( 'path.to.mysettings) django.core.management °¡Á® ¿À±â execute_from_command_line execute_from_command_line (SYS.ARGV) WSGI ÆÄÀÏ¿¡ ºñ½ÁÇÑ ¼öÁ¤À»ÇؾßÇÕ´Ï´Ù. SENTALLY º¯°æ »çÇ× ¸¸ º¯°æÇÕ´Ï´Ù. Django°¡ Creating Create°¡ Ŭ·¡½ºÀÇ ¸ðµç º¯¼ö¸¦ ÁßøÇÏ´Â °ÍÀÔ´Ï´Ù. cbsettings¿¡¼­ .Settings DjangodeFaultSclass MySettings (djangodefaults) : Admins = (# ( 'À̸§', 'your_email@example.com'),) °ü¸®ÀÚ = °ü¸®ÀÚ µ¥ÀÌÅͺ£À̽º = { 'default': { 'Engine': 'django.db.backends . ','À̸§ ':' ','»ç¿ëÀÚ ':' ','¾ÏÈ£ ':', 'È£½ºÆ®': ','Æ÷Æ® ':', ',',}} µîµîÀº djangodefaults¸¦ È®ÀåÇÕ´Ï´Ù. ÀÌ Å¬·¡½º¿¡¼­ »ó¼ÓÇϸé Django°¡ Á¤»óÀûÀ¸·Î ¼³Á¤À» º¹ÇÕÇÏ´Â ¸ðµç ±âº» ¼³Á¤ °ªÀ» ¸ðµÎ °¡Á®¿É´Ï´Ù. (À̵éÀº django.conf.global_settings¿¡¼­ ²ø¾î ´ç°ÜÁý´Ï´Ù. Custom.StaticFileFinder ',) # etcthese´Â ÀϹÝÀûÀ¸·Î ÀϹÝÀûÀ¸·Î ÇÒ ¼öÀÖ´Â ÀÏÀ» ÇÒ ¼ö ÀÖ½À´Ï´Ù. Return Self.Debug # excussing ¼³Á¤ FactoryYou´Â ¼³Á¤ ¸ðµâÀÇ DjangoÀÇ Çϵå Äڵ带 ÆÄÀÏ·Î Çϵå ÄÚµùÇÏ´Â °Í°ú °°½À´Ï´Ù. ±×°Ç »ç½ÇÀ̾ß. ±×·¡¼­ () ±¸¼º ()Àº ¼³Á¤ °´Ã¼ ÀνºÅϽº¸¦ ¹ÝȯÇϴ ȣÃâ °¡´ÉÇÑ ¸ðµç È£Ãâ °¡´ÉÀ¸·Î °æ·Î¸¦ Àü´ÞÇÒ ¼ö ÀÖ½À´Ï´Ù. µû¶ó¼­ Manage.py´Â ´ë½Å ´ÙÀ½°ú °°ÀÌ º¸ÀÏ ¼ö ÀÖ½À´Ï´Ù. #! / usr / bin / env pythonimport sysimport cbsettingsif __name__ == "__main__": cbsettings.configure ( 'path.to.my.settings.factory') django.core¿¡¼­. °ü¸® impute_from_command_line execute_from_command_line (sys.argv) ±×·± ´ÙÀ½ path / to / my / settings.py : def factory () : OS.Environ¿¡ 'dev'°¡ÀÖ´Â °æ¿ì myDebugSettings () else : return myProductionSettings () ÀÌÁ¦ ½±°Ô ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿©·¯ ÆÄÀÏÀ» ¼öÁ¤ÇÏÁö ¾Ê°íµµ ¿øÇÏ´Â ¸ðµç Á¶°ÇÀ» ±â¹ÝÀ¸·Î »ç¿ëÁßÀÎ ¼³Á¤ Ŭ·¡½º¸¦ º¯°æÇϽʽÿÀ. SwitcherUsing »ç¿ëÇÒ ¼³Á¤ Ŭ·¡½º¸¦ °áÁ¤ÇÏ´Â ÆÑÅ丮 ¸Þ¼Òµå´Â °­·ÂÇÑ ±â´ÉÀÔ´Ï´Ù! ±×·¯³ª ÀϹÝÀûÀ¸·Î µ¿ÀÏÇÑ Á¾·ùÀÇ Á¶°ÇÀ» ±â¹ÝÀ¸·Î ¼³Á¤ Ŭ·¡½º¸¦ ÀüȯÇϱ⸦ ¿øÇÒ ¼ö ÀÖÀ¸¹Ç·Î Django-ClassBaseDettings´Â ÀÌ·¯ÇÑ ÀϹÝÀûÀÎ °æ¿ì¸¦ ó¸® ÇÒ °øÀå°ú ÇÔ²² Á¦°øµË´Ï´Ù. ¶ÇÇѺ¸´Ù ¼±¾ðÀû ±¸¹®À» »ç¿ëÇϹǷΠ°øÀå ¹æ½Äº¸´Ù ´õ Á¶Á÷È­µË´Ï´Ù. ´ÙÀ½Àº ¼³Á¤ ÆÄÀÏ¿¡¼­ »ç¿ë ¹æ¹ýÀÔ´Ï´Ù. CBSETTINGS °¡Á® ¿À±â CBSETTINGSTETTINGS IMPORT DJANGODEFAULTS (DJANGODEFAULTS) : DEBUG = FALSES (DJANGODEFAULTS) : DEBUG = TRUE # ETSSWITTER.REGISTER (MyProductionSettings, Hostnames = com ']) switcher.register (myDevSettings, hostnames = ) decorator·Î switcher.register¸¦ »ç¿ëÇÒ ¼öµµ ÀÖ½À´Ï´Ù. cbsettings °¡Á® ¿À±â switcherfrom cbsettings.settings °¡Á® ¿À±â djangodefaults@switcher.registers (Hostnames = ) Ŭ·¡½º MyProductionSettings (djangodeFaults) : debug = false # etc@switcher.register (hostnames = ) Ŭ·¡½º MyDevSettings (djangodefaults) : µð¹ö±× = Configure¸¦ È£ÃâÇÏ°íÀÖ´Â °÷ÀÌ¸é ¾îµð¿¡¼­³ª ¸ðµâÀÇ ½ºÀ§Ã³ º¯¼ö¸¦ Àü´ÞÇϽʽÿÀ. CBSetTINGS.CONFIGURE ( 'PATH.TO.MY.SETTINGS.SWITCHER') Á¦Ç°ÀÇ È¨ÆäÀÌÁö


Django-classbasedsettings. °ü·Ã ¼ÒÇÁÆ®¿þ¾î