Àå°í ´ÙÀ̳ª¹Í ÆäÁöµ¿ÀûÀ¸·Î º¯°æµÇ´Â URLÀ» Çã¿ëÇÏ´Â ÀÀ¿ë ÇÁ·Î±×·¥ | |
Áö±Ý ´Ù¿î·Îµå |
Àå°í ´ÙÀ̳ª¹Í ÆäÁö ¼øÀ§ ¹× ¿ä¾à
±¤°í
Àå°í ´ÙÀ̳ª¹Í ÆäÁö ű×
Àå°í ´ÙÀ̳ª¹Í ÆäÁö ¼³¸í
Django-DynamicPages´Â CMS ½Ã½ºÅÛÀÌ ¾Æ´ÏÁö¸¸ °³¹ßÀÚ¸¦ ´Ü¼øÈÇÏ¸é ¼¹ö¸¦ ´Ù½Ã ½ÃÀÛÇÏÁö ¾Ê°í URLÀ» º¯°æÇÏ´Â ¿É¼ÇÀÌÀÖ´Â µ¿Àû ÆäÀÌÁö¸¦ ¸¸µì´Ï´Ù. ÅÛÇø´¿¡¼ »ç¿ëÇÒ ¼öÀÖ´Â »ç¿ëÀÚ Á¤ÀÇ ÆäÀÌÁö ÄÁÅÙÃ÷¸¦ Ãß°¡ ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¸ÕÀú Djagno-Simple-Utilities PIP ¼³Ä¡ -u Django-Simple-Utilities¸¦ ¼³Ä¡ÇÏ°í ¸¶Áö¸·À¸·Î Django-Dynamic Pages PIP ¼³Ä¡ -u Django-Dynamic-PageSconfiguration ¼³Ä¡ : settings.py : django.contrib.admin : instedual_apps = (... 'À¯Æ¿¸®Æ¼', 'dynamic_pages', 'django.contrib.admin', ...) installation_apps = (... 'À¯Æ¿¸®Æ¼', ','dynamic_pages.middleware¸¦ Ãß°¡ÇϽʽÿÀ. URLSRELOADMIDDLEWARE 'to middleware_classes ¹×'dynamic_pages.context_processors.page_contextsorls.py : firstly dynamic_pages.dynamic.utils¿¡¼ django ÆÐÅÏ¿¡ dnamic_patterns¿¡ dynamic_ulpatterns urlpatterns + = dynamic_urlpatterns ()¸¦ °¡Á®¿Ã ¼ö ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, dynamic_pages.dynamic.dynamic_urls dynamicurl default_dynamic_urls = (dynamicurl ( 'static', _ (u'static ÆäÀÌÁö '), staticview.as_view (), (r' '',), 'dynamic_pages.staticpag eContent '), dynamicurl ('¸®µð·º¼Ç ', _ (u'redirects', _)), dynamicurl ( 'redirectstourl', _ (u'redirect to url '), ¾øÀ½, ¾øÀ½,'dynamic_pages.redirecttourlpageContent ', can_change_url = false), dynamicurl ( 'redirectstopage', _ (u'redirect to page '), ¾øÀ½,'dynamic_pages.redirecttopagePageContent ', CAN_CHANGE_PAGECONTENT', CAN_CHANGE_URL = false) Ŭ·¡½º µ¿Àû URLÀÌ »ý¼ºÀÚ°¡ ÀÖ½À´Ï´Ù. dynamicurl (name, verbose_name, view = none, patterns = [], model = none, can_change_url = true, view_kwargs = none) name - dynamic_pattern verbose_nameÀÇ °íÀ¯ ÇÑ À̸§ - °ü¸®º¸±â¿¡¼ »ç¿ëµÇ´Â À̸§ - Django Ŭ·¡½ºº¸±â ¶Ç´Â ÇÔ¼ö ÆÐÅÏ - URL ÆÐÅÏÀÇ Django Ŭ·¡½ºº¸±â ¶Ç´Â ¹®ÀÚ¿ °æ·Î. ¸ðµç ÆÐÅÏÀº °ü¸®¿¡¼ º¯°æ µÉ ¼ö ÀÖÁö¸¸ °ü¸®¿¡¼ ¼³Á¤µÈ URL ÀÌÀÌ ¸ðµç Paterns¿¡ Á¢µÎ¾î¸¦ ¸¸µì´Ï´Ù. °ü¸® ¼¼Æ® ÆÐÅÏ¿¡¼ ¸ðµ¨·Î Àüü URLÀ» ÆíÁý ÇÒ ¼öÀÖ´Â °æ¿ì »ç¿ëÀÚ Á¤ÀÇ PageContent¸¦ ¸¸µé ¼ö ÀÖ½À´Ï´Ù.ÀÌ ¸ðµ¨Àº PageContent ¸ðµ¨À» È®ÀåÇؾßÇÕ´Ï´Ù. ÆäÀÌÁö ³»¿ëÀº ÅÛÇø´¿¡¼ PAGE_CONTENT º¯¼ö·Î »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÌ °ªÀº app_name.model_name can_change_urlÀ» Æ÷ÇÔÇÏ´Â ¹®ÀÚ¿À̾î¾ßÇÕ´Ï´Ù.ÀÌ °ªÀº false·Î ¼³Á¤µÇ¸é URLÀ» µ¿ÀûÀ¸·Î º¯°æÇÒ ¼ö ¾ø½À´Ï´Ù. view_kwargs - URL view_kwargscustom ÆäÀÌÁö ³»¿ë°ú µ¿ÀÏÇÑ °ª : pageContent´Â À¥ ÆäÀÌÁö µ¥ÀÌÅÍ°¡ Æ÷ÇÔ µÈ ¸ðµ¨ÀÔ´Ï´Ù. ¸ðµç ÆäÀÌÁö¿¡´Â ÇÑ ÆäÀÌÁö ³»¿ëÀÌ Çϳª ÀÖ½À´Ï´Ù. model.py ÆÄÀÏ¿¡¼ ¾Û¿¡¼ »ç¿ëÀÚ Á¤ÀÇ ÆäÀÌÁö ÄÁÅÙÃ÷¸¦ ¸¸µé ¼ö ÀÖ½À´Ï´Ù. ¿¹ : Class HomePageContent (pageContent) : html = htmlfield (_ (u'text '), blank = true) def __unicode __ (self) :'% s '% forue_unicode (_ (u'home ÆäÀÌÁö ³»¿ë')); Class Meta : verbose_name = _ verbose_name_plural = _ (u'home ÆäÀÌÁö ÄÁÅÙÃ÷ ') ¹×ÀÌ ¸ðµ¨ Ŭ·¡½ºÀÇ °æ·Î·Î ¿À¸¥ÂÊ ´ÙÀÌÀ̱׷¥ rl¿¡¼ ¸ðµ¨À» ¼³Á¤Çϸé Page_Content º¯¼ö¿¡ ÅÛÇø´ ¿¡ÀÌ ÆäÀÌÁö ³»¿ëÀÌ Æ÷ÇԵ˴ϴÙ. page_utils : page_utils ÅÛÇø´ űװ¡ µé¾î ÀÖ½À´Ï´Ù. ÅÛÇø´¿¡¼ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. {% load page_utils %} dynamicurl : µ¿Àû ÆäÀÌÁö¿¡¼ ÅÛÇø´ ÅÂ±× URLÀÌ ÀÛµ¿ÇÏÁö ¾ÊÀ¸¹Ç·Î tag dynamicurl {% dynamicurl dynamic_pattern_name val1 val2 ... %} get_query_string : {% get_query_string remove : a, b new_params : c = 5, d = 'e'%} - Äõ¸®¿¡¼ Äõ¸® A¿Í B¸¦ Á¦°ÅÇÏ°í °ª 5 ¹× '°³°³ÀÎÀÇ È¨ÆäÀÌÁö·Î Äõ¸® C ¹× D¸¦ Ãß°¡ÇÏ´Â Äõ¸® ¹®ÀÚ¿À» ¹ÝȯÇÕ´Ï´Ù.
Àå°í ´ÙÀ̳ª¹Í ÆäÁö °ü·Ã ¼ÒÇÁÆ®¿þ¾î
Àå°í ºÒÇà
DjangoÀÇ °£´ÜÇÑ ±ÝÁö ½Ã½ºÅÛ, ±ÍÇÏÀÇ À¥ »çÀÌÆ®¿¡¼ ¹æȲÇÏ´Â Æ®·ÑÀ» Æ®·Ñ¸µÇÏ´Â °ÍÀÔ´Ï´Ù. ...
56