from django.conf.urls import url, include
from . import views
#utl 配置,从blog目录下,如果不导入,显示找不到路径
urlpatterns = [
url(r'^index/$', views.index),
url(r'^article/(?P<article_id>[0-9]+)$', views.article_page, name='article_page'),
url(r'^edit/$', views.edit_page, name='edit_page'),
url(r'^edit/action$', views.edit_action, name='edit_action'),
]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Edit Page</title>
</head>
<body>
<form action="{% url 'blog:edit_action' %}" method="post">
{% csrf_token %}
<label>文章标题
<input type="'text" name="title"/>
</label>
<br/>
<label>文章内容
<input type="text" name="content"/>
</label>
<br/>
<input type="submit" value="提交">
</form>
</body>
</html>
"""myblog URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url,include
from django.contrib import admin
#utl 配置
#第二个参数的namespace='xx',
# 配置超链接的URL格式{% url 'app_name : url_name' param %}
# app_name是命名空间,总的urls中修改,include的第二个参数namespace=,
# url_name是项目路径(blog\urls)下的第三个参数name=,参数传的是article.id
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^blog/', include('blog.urls', namespace='blog'),)
]