Exemple #1
0
from django.views.static import serve

from myblog.views import IndexView, ArichiveView, TagView, TagDetailView, BlogDetailView
from myblog.views import AddCommentView, CategoryDetaiView, MySearchView
from myblog.feeds import BlogRssFeed
from blog.settings import STATIC_ROOT


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^archive/$', ArichiveView.as_view(), name='archive'),
    url(r'^tags/$', TagView.as_view(), name='tags'),
    url(r'^tags/(?P<tag_name>\w+)$', TagDetailView.as_view(), name='tag_name'),
    url(r'^blog/(?P<blog_id>\d+)$', BlogDetailView.as_view(), name='blog_id'),
    url(r'^add_comment/$', AddCommentView.as_view(), name='add_comment'),
    url(r'^rss/$', BlogRssFeed(), name='rss'),
    url(r'^category/(?P<category_name>\w+)/$', CategoryDetaiView.as_view(), name='category_name'),
    url(r'^search/', MySearchView(),  name='haystack_search'),
    #添加静态文件的访问处理函数
    url(r'^static/(?P<path>.*)/$', serve, {'document_root': STATIC_ROOT}),

]


# 配置全局404页面
hander404 = 'myblog.views.page_not_found'

# 配置全局505页面
hander505 = 'myblog.views.page_errors'
Exemple #2
0
from django.contrib import admin
from django.views.static import serve

from myblog.views import IndexView, ArichiveView, TagView, TagDetailView, BlogDetailView, AddCommentView, CategoryDetaiView, MySearchView
from myblog.feeds import BlogRssFeed
from blog.settings import STATIC_ROOT
from myblog import views

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^archive/$', ArichiveView.as_view(), name='archive'),
    url(r'^tags/$', TagView.as_view(), name='tags'),
    url(r'^tags/(?P<tag_name>\w+)$', TagDetailView.as_view(), name='tag_name'),
    url(r'^blog/(?P<blog_id>\d+)$', BlogDetailView.as_view(), name='blog_id'),
    url(r'^add_comment/$', AddCommentView.as_view(), name='add_comment'),
    url(r'^rss/$', BlogRssFeed(), name='rss'),
    url(r'^category/(?P<category_name>\w+)/$',
        CategoryDetaiView.as_view(),
        name='category_name'),
    url(r'^search/', MySearchView(), name='haystack_search'),
    #添加静态文件的访问处理函数
    url(r'^static/(?P<path>.*)/$', serve, {'document_root': STATIC_ROOT}),
    url(r'^pic_show/myblog1986(\d+)21xmj20200820$', views.pic_show),
    url(r'^music/$', views.listenMyMusic),
    url(r'^step/music/$', views.listenMyMusic),
    url(r'^step/$', views.MyStep),
]

# 配置全局404页面
hander404 = 'myblog.views.page_not_found'
Exemple #3
0
"""SuixinSite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    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.contrib import admin
from django.urls import path
from myblog.views import IndexView, BlogDetailView, AddCommentView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('blog/', IndexView.as_view(), name='index'),
    path('blog/(?P<blog_id>\d+)$', BlogDetailView.as_view(), name='detail'),
    path('add_comment/', AddCommentView.as_view(), name='add_comment'),
]