2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.urls import path, re_path from blog.views import IndexView, PostView, TagView, ArchiveView, CategoryView, SearchView app_name = "blog" urlpatterns = [ re_path('^$', IndexView.as_view(), name='index'), re_path('post/(?P<pk>[0-9]+)/', PostView.as_view(), name='detail'), #文章归档目录页 re_path('tag/(?P<pk>[0-9]+)/', TagView.as_view(), name='tag'), #导航分类页 re_path('category/(?P<pk>[0-9]+)/', CategoryView.as_view(), name='category'), #文章归档目录页 re_path('archive/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/', ArchiveView.as_view(), name='archive'), #搜索页 re_path('search/', SearchView.as_view(), name='search'), ]
from django.conf.urls import url from blog.views import ArchiveView, CategoryListView, EntryDetailView urlpatterns = [ url(r'^archivio/?$', ArchiveView.as_view(), name='blog-archive'), url(r'^categoria/(?P<tag>.+)/$', CategoryListView.as_view(), name='blog-category-list'), url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$', EntryDetailView.as_view(), name='blog-detail'), ]
from blog.views import IndexView, PostView, AboutView, ArchiveView, CategoryView, CategoryPostView from .settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^$', IndexView.as_view(), name="index"), # 文章详情页 url(r'^post/(?P<post_id>\d+)/$', PostView.as_view(), name="post"), # 关于作者 url(r'^about/$', AboutView.as_view(), name="about"), # 登陆 url(r'^login/$', AboutView.as_view(), name="login"), # 注册 url(r'^register/$', AboutView.as_view(), name="register"), # 归档 url(r'^archives/$', ArchiveView.as_view(), name="archives"), # 分类 url(r'^categories/$', CategoryView.as_view(), name="categories"), # url(r'^static/(?P<path>.*)$', serve, {"document_root":STATIC_ROOT}), # 同种分类文章 url(r'^category/(?P<category_id>\d+)/$', CategoryPostView.as_view(), name="category_post"), # 配置上传文件的访问处理函数 url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), ] # 全局404页面配置
from django.conf.urls import url from blog.views import ArticleView,CategoryView,UserView,IndexView,CommentView,SearchView,AboutView,TagView,ArchiveView from django.views.generic import TemplateView urlpatterns=[ url(r'^$',IndexView.as_view()), url(r'^article/(?P<slug>\w+).html',ArticleView.as_view()), url(r'^category/(?P<category>\w+)/$',CategoryView.as_view()), url(r'^user/(?P<slug>\w+)/$',UserView.as_view()), url(r'^login/$',TemplateView.as_view(template_name="blog/login.html")), url(r'^register/$',TemplateView.as_view(template_name="blog/register.html")), url(r'^comment/(?P<slug>\w+)$',CommentView.as_view()), url(r'^search/$',SearchView.as_view()), # url(r'^about/$',TemplateView.as_view(template_name="blog/about.html")), url(r'^about/$',AboutView.as_view()), url(r'^tag/(?P<tag>\w+)/$',TagView.as_view()), url(r'^archives/$',ArchiveView.as_view()), ]
#!usr/bin/python3 #-*- coding:utf-8 -*- from django.conf.urls import url from django.urls import re_path, path from blog.views import CategoryView, ArchiveView, DetailView, TagView, AboutView, ConnectView,SearchView app_name='blog' urlpatterns = [ # 文章详情页 re_path('post/(?P<pk>[0-9]+)/', DetailView.as_view(),name='detail'), # 按年月查找 re_path('archives/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/', ArchiveView.as_view(), name='archives'), # 按分类查找 re_path('category/(?P<pk>[0-9]+)/', CategoryView.as_view(), name='category'), # 按分类查找 re_path('tag/(?P<pk>[0-9]+)/', TagView.as_view(), name='tag'), path('about/', AboutView.as_view(), name='about'), path('connect/', ConnectView.as_view(), name='connect'), path('search/', SearchView.as_view(), name='search'), ]
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.views.static import serve import xadmin from blog.views import BlogView, CategoryView, ArchiveView, AboutView, ContentView, TagView from wangcwblog.settings import MEDIA_ROOT urlpatterns = [ url(r'^$', BlogView.as_view(), name='home'), url(r'^xadmin/', xadmin.site.urls), url(r'^categories/$', CategoryView.as_view(), name='categories'), url(r'^category/(?P<category_id>[0-9]+)$', CategoryView.as_view(), name='category_id'), url(r'^archives/$', ArchiveView.as_view(), name='archives'), url(r'^tags/$', TagView.as_view(), name='tags'), url(r'^tag/(?P<tag_id>[0-9]+)$', TagView.as_view(), name='tag_id'), url(r'^about/$', AboutView.as_view(), name='about'), url(r'^content/(?P<article_id>[0-9]+)$', ContentView.as_view(), name='content'), url(r'^ueditor/', include('DjangoUeditor.urls')), url(r'media/(?P<path>.*)', serve, {'document_root': MEDIA_ROOT}), ]
#!/usr/bin/python3 # encoding: utf-8 # @Time : 2019/3/3019:37 # @Author Superficial # @File urls.py # @Software PyCharm from django.urls import path, re_path from blog import views from blog.views import IndexView, DetailView, CategoryView, TagView, ArchiveView app_name = 'blog' urlpatterns = [ re_path('^$', IndexView.as_view(), name='index'), re_path(r'^category/(?P<nav_slug>.*?)/(?P<slug>.*?)$', CategoryView.as_view(), name='category'), re_path(r'tag/(?P<tag_name>.*?)/$', TagView.as_view(), name='tag'), path(r'article/<int:year>/<int:month>/<int:day>/<int:article_id>.html', DetailView.as_view(), name='detail'), re_path(r'archive/$', ArchiveView.as_view(), name='archive'), # 归档页面 # 全文搜索 # re_path(r'^search/$', MySearchView.as_view(), name='search'), re_path(r'^search/$', views.search, name='search'), re_path(r'^about/$', views.about, name='about'), ]