DJango_FriendLyURLS. ¼øÀ§ ¹× ¿ä¾à
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://github.com/tachang/
DJango_FriendLyURLS. ű×
DJango_FriendLyURLS. ¼³¸í
DJango_FriendLyURLS´Â Django ¾ÛÀ» »ç¿ëÇÏ¿© View¸¦ Á÷Á¢ ¹ÝȯÇÏ´Â URLÀ» ¸¸µé ¼ö ÀÖ½À´Ï´Ù. HTTP : //www.example.com/jeffthe Å°¸¦ »ç¿ëÀÚ¿¡°Ô ¾×¼¼½º ÇÒ ¼ö ÀÖµµ·Ï URLÀ» ¸¸µé ¼ö ÀÖ½À´Ï´Ù. ºê¶ó¿ìÀúÀÇ ÁÖ¼Ò Ç¥½Ã ÁÙÀÌ http : //www.example·Î º¯°æµÇÁö ¾Ê´Â´Ù´Â °ÍÀÔ´Ï´Ù. COM / USER / 1 À¥ ¼¹ö´Â http://www.example.com/user/1flow°¡ µ¿ÀÏÇÑ HTML ¹®¼¸¦ ¹ÝȯÇÕ´Ï´Ù. ÀÀ¿ë ÇÁ·Î±×·¥Àº Ä£¼÷ÇÑ URL ÀÏÄ¡¸¦ ãÀ¸¸é 'Jeff'¹®ÀÚ¿À» ã½À´Ï´Ù. URL Resolver¸¦ 2 ¹ø° ½Ã°£À» º¸³»¸é ÇØ°áÇϽʽÿÀ. ÇØ°á ¹æ¹ýÀ» ãÀ¸¸é ÇØ°áÃ¥À» ãÀ¸¸é ÇØ´ç view.USAgehere´Â »ç¿ëÀÚ¸¦ À§ÇØ Friendly_urls¸¦ ±¸ÇöÇÏ´Â ¹æ¹ýÀÇ ¿¹ÀÔ´Ï´Ù. ipples.py:from Django.contrib¿¡¼ ÀÌ°ÍÀ» ³Ö½À´Ï´Ù. ContentTypes GenericFrom FriendMoorls °¡Á® ¿À±â UrlMappingFrom Django.contrib.auth.models userdef °¡Á® ¿À±â get_absolute_url (self) : u '/ user / % s'% self.iduser.add_to_class ( 'friendly_urls', generic.genericration (UrlMapping)) user.get_absolute_url = get_absolute_urlthis ±âº»ÀûÀ¸·Î ¿ø¼þÀÌ°¡ »ç¿ëÀÚ ¸ðµ¨À» ÆÐÄ¡ÇÏ¿© Çʵ带 Ãß°¡ÇÕ´Ï´Ù. ±×·± ´ÙÀ½ douser = user.objects.get (pk = 1) user.friendly_urls.all () ÀÌ°ÍÀº ¸ðµç Ä£ÈÀû ÀÎ URLÀÇ ¸ñ·ÏÀ» ¾òÀ» ¼ö ÀÖ½À´Ï´Ù. ¿ø¼þÀÌ ÆÐÄ¡¿¡ ¸ðµç ¸ðµ¨À» »ç¿ëÇÒ ¼ö ¾ø¾î¾ßÇÕ´Ï´Ù .Problems / complays FriendlyURLÀÌ URL Mappings¸¦ ÀúÀåÇϱâÀ§ÇÑ Å×À̺íÀ» ¸¸µå´Â µ¥ SyncDB¸¦ ½ÇÇàÇÏ´Â °ÍÀ» ÀØ¾î ¹ö¸®½Ê½Ã¿À. Path¸¦ ãÀ¸·Á°í ÇÒ ¶§ »ç·Ê¸¦ ¹«½ÃÇÏ·Á´Â °æ¿ì True·Î ¼³Á¤ÇϽʽÿÀ. ±âº»°ª : falseProductÀÇ È¨ÆäÀÌÁö
DJango_FriendLyURLS. °ü·Ã ¼ÒÇÁÆ®¿þ¾î