Exemplo n.º 1
0
"""myblog URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/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 blog.views import IndexView, TagView,CategoryView,TagDetailView,CategoryDetailView,BlogDetailView
from comment.views import AddCommet
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', IndexView.as_view(), name='index'),
    path('tags/', TagView.as_view(), name='tags'),
    path('category/', CategoryView.as_view(), name='category'),
    path('tags/<tagDetail>', TagDetailView.as_view(), name='tagDetail'),
    path('category/<categoryDetail>', CategoryDetailView.as_view(), name='categoryDetail'),
    path('blog/<blogDetail>', BlogDetailView.as_view(), name='blogDetail'),
    path('add_comment/<add_comment>', AddCommet.as_view(), name='add_comment'),
]
Exemplo n.º 2
0
from blog.sitemaps import BlogSitemap

from blog.views import BlogIndexView, BlogDetailView, \
     BlogPostsAtomFeed, BlogPostsRssFeed, TagDetailView, BlogSearchView, LegacyPostRedirectView

urlpatterns = patterns(
    '',

    # blog urls
    url(r'^$', BlogIndexView.as_view(), name="blog"),
    url(r'^search$', BlogSearchView.as_view(), name="blog_search"),
    url(r'^post/(?P<slug>[-\w]+)/$',
        BlogDetailView.as_view(),
        name="blog_detail"),
    url(r'^tag/(?P<slug>[-\w]+)/$',
        TagDetailView.as_view(),
        name="blog_tag_detail"),

    # rss & atom feed
    url(r'^feed/rss$', BlogPostsRssFeed(), name="blog_rss_feed"),
    url(r'^feed/atom', BlogPostsAtomFeed(), name="blog_atom_feed"),

    # sitemap
    url(r'^sitemap\.xml$',
        'django.contrib.sitemaps.views.sitemap',
        {'sitemaps': dict(blog=BlogSitemap())},
        name="blog_sitemap"),

    # legacy urls for oldest tumblr blog.
    url(r'^post/(?P<legacy_post_id>\d+)',
        LegacyPostRedirectView.as_view(),
Exemplo n.º 3
0
from django.urls import path
from .feeds import PostFeed

app_name = 'blog'
urlpatterns = [
    path('published/', PostIndexView.as_view(), name='post-list'),
    path('drafts/', PostDraftView.as_view(), name='post-draft-list'),
    path('contact/', contact, name='contact'),
    path('about/', about, name='about'),
    path('', index, name='home'),
    path('feeds/', PostFeed(), name='post-feed'),
    path('tags/', TagListView.as_view(), name='tag-list'),
    path('tag/create/', TagCreateView.as_view(), name='tag-create'),
    path('tag/<int:pk>/delete/', TagDeleteView.as_view(), name='tag-delete'),
    path('tag/<int:pk>/update/', TagUpdateView.as_view(), name='tag-update'),
    path('tag/<str:slug>/', TagDetailView.as_view(), name='tag-detail'),
    path('categories/', CategoryListView.as_view(), name='category-list'),
    path('category/create/',
         CategoryCreateView.as_view(),
         name='category-create'),
    path('category/<int:pk>/delete/',
         CategoryDeleteView.as_view(),
         name='category-delete'),
    path('category/<int:pk>/update/',
         CategoryUpdateView.as_view(),
         name='category-update'),
    path('category/<str:slug>/',
         CategoryDetailView.as_view(),
         name='category-detail'),
    path('post/create/', PostCreate.as_view(), name='post-create'),
    path('comment/<int:pk>/remove/', comment_remove, name='comment-remove'),
Exemplo n.º 4
0
from django.views.generic.base import RedirectView
from blog.sitemaps import BlogSitemap

from blog.views import BlogIndexView, BlogDetailView, \
     BlogPostsAtomFeed, BlogPostsRssFeed, TagDetailView, BlogSearchView, LegacyPostRedirectView


urlpatterns = patterns('',

    # blog urls
    url(r'^$', BlogIndexView.as_view(), name="blog"),
    url(r'^search$', BlogSearchView.as_view(), name="blog_search"),
    url(r'^post/(?P<slug>[-\w]+)/$',
        BlogDetailView.as_view(), name="blog_detail"),
    url(r'^tag/(?P<slug>[-\w]+)/$',
        TagDetailView.as_view(), name="blog_tag_detail"),

    # rss & atom feed
    url(r'^feed/rss$', BlogPostsRssFeed(), name="blog_rss_feed"),
    url(r'^feed/atom', BlogPostsAtomFeed(), name="blog_atom_feed"),

    # sitemap
    url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': dict(
        blog=BlogSitemap()
    )}, name="blog_sitemap"),

    # legacy urls for oldest tumblr blog.
    url(r'^post/(?P<legacy_post_id>\d+)',
        LegacyPostRedirectView.as_view(), name="legacy_blog_detail"),
    url(r'^tagged/(?P<slug>[-\w]+)', RedirectView.as_view(
        url="/tag/%(slug)s/", permanent=True), name="legacy_blog_tag_detail"),
Exemplo n.º 5
0
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

from blog.models import Entry, Link
from blog.views import TagDetailView, TagDetailEntryView, TagDetailLinkView

urlpatterns = patterns('',
    
    url(r'^$', direct_to_template, {'template': 'blog/tag_list.html'}, 'blog_tag_list'),
    
    url(r'^(?P<tag_slug>[-\w]+)/$', TagDetailView.as_view(template_name='blog/tag_detail.html')),
    
    url(r'^(?P<tag_slug>[-\w]+)/links/$', TagDetailLinkView.as_view(paginate_by=5, 
                                                                template_name='blog/tag_detail_link.html')),
    
    url(r'^(?P<tag_slug>[-\w]+)/news/$', TagDetailEntryView.as_view(paginate_by=5, 
                                                               template_name='blog/tag_detail_entry.html')),

)
Exemplo n.º 6
0
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from blog.views import index2
from blog.views import IndexView, ArichiveView, TagView, TagDetailView, BlogDetailView
from blog.views import AddCommentView, CategoryDetaiView, MySearchView
from blog.feeds import BlogRssFeed
# from blogs.settings import STATIC_ROOT
from django.views.static import serve

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