1.程序所有均开始于mysite的settings -> ROOT_URLCONF = 'mysite.urls'
from .views import *
urlpatterns = [
url(r'^$', post_list, name='home'),
url(r'', include('blog.urls')), # 引用到其它模块的url
url(r'^admin/', include(admin.site.urls)),
url(r'^add_picture/add/(?P<pk>[0-9]+)/$', add_picture, name='add_picture'),
]
from .views import hello
urlpatterns = patterns('',
url(r'^hello/$', hello),
)
2.
<form action="{% url 'blog.views.add_comment' pk=post.pk %}" method="POST" id="commentform">
由html中的url转向 mysite中的url 按照r'^add_picture/add/(?P<pk>[0-9]+)/$'生成网址 -> 调用view视图中的函数add_picture
django URL学习
最新推荐文章于 2019-08-17 17:58:25 发布