django 개발 포인트 - URL 구성

2411 단어 django
#coding=utf-8

from django.conf.urls import include, url
from django.contrib import admin
from DjangoUeditor import urls as DjangoUeditor_urls
from django.conf import settings
from .constant import *
from django.conf.urls.static import static

"""
   
1.(?Pxxxx)              ,               
	     (?P=tag_name),  tag_name  URL           
2.      [] ()       ,      。          。
3.name     url   ,              URL
	(1)    
	' %}">
	(3) tag      
	
4.            /xxx/   URL          
	     (?P[A-Z]+):(?P.+)/$
	             
5.    settings.DEBUG   debug release            
	      
6,NoReverseMatch.              urlpatterns  name    ,name   
  reverse          ,reverse       viewname(    )
7.django        
  *static STATIC_URL   
  /static/xxxxx      host   
  static/xxxxxx        reference   
    django         :
  1.        
    {%load staticfiles%}
   	{%static 'xxx/xxxx'%} 
  2.      
    /static/xxxxxx
  3. STATIC_URL         
    {{STATIC_URL}}xxx/xxx/xxx
"""

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
	url(r'^ueditor/', include(DjangoUeditor_urls)),
	url(r'^column/(?P[^/]+)/$', 'news.views.column' ,name=URL_NAME_COLUMN),
	#url(r'^article/(?P[^/]+)/$','news.views.article', name=URL_NAME_ARTICLE),
	url(r'^(?P\d+)/(?P[^/]+)/$','news.views.article', name=URL_NAME_ARTICLE),
	url(r'^re/(?P[A-Z]+):(?P.+)/$','news.views.re', name="news_re_demo"),
	url(r'^$','news.views.index', name="index"),

	#  static   ,name static
	#static(settings.STATIC_URL, document_root=settings.STATIC_ROOT),
	#url(r'^static/(?P.*)$','django.views.static.serve',{'document_root':settings.STATIC_ROOT}),
]

"""
static(url,document_root)              ,
          ,       

             ,URL STATIC_URL/xxxx   
"""
if settings.DEBUG:
	urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)	

좋은 웹페이지 즐겨찾기