Пример #1
0
from django.conf.urls import patterns, url
from blog.views import PostIndexView, PostDetailViewBySlug, PostDetailViewById


urlpatterns = patterns(
    'blog.views',
    url(r'^$', PostIndexView.as_view()),
    url(r"^(?P<id>[\d+])$", PostDetailViewById.as_view()),
    url(r"^(?P<slug>[-\w]+)/$", PostDetailViewBySlug.as_view(), name="post_detail"),
)
Пример #2
0
from blog.views import PostCreate, PostDetailView, PostUpdate, PostDelete, PostIndexView, PostDraftView, post_publish, \
    PostComment, comment_approve, comment_remove, contact, about, index, TagListView, TagCreateView, TagUpdateView, \
    TagDetailView, \
    TagDeleteView, CategoryListView, CategoryCreateView, CategoryDetailView, CategoryUpdateView, CategoryDeleteView
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>/',
Пример #3
0
    path('contact/', ContactView.as_view(), name='contact'),
    path('blogroll/', BlogrollView.as_view(), name='blogroll'),
    path('reviews/', ReviewsView.as_view(), name='reviews'),
    path('sitemap.xml', sitemap_views.index, {'sitemaps': sitemaps}),
    path('sitemap-<section>.xml',
         sitemap_views.sitemap, {'sitemaps': sitemaps},
         name='django.contrib.sitemaps.views.sitemap'),
    path('captcha/', include(captcha_urls)),
    path('tag/<url>/',
         RedirectView.as_view(
             url="/blog/tag/%(url)s",
             permanent=True)),  # some catch alls to reduce 404 errors
    path('page/<url>/',
         RedirectView.as_view(url="/blog/page/%(url)s", permanent=True)),
    path('<int:year>/',
         RedirectView.as_view(url="/blog/%(year)s", permanent=True)),
    path('<int:year>/<url>/',
         RedirectView.as_view(url="/blog/%(year)s/%(url)s", permanent=True)),
    path('category/<url>/page/<page>/', CategoryRedirectView.as_view()),
    path('category/<url>/', CategoryRedirectView.as_view()),
    path('', PostIndexView.as_view(), name='index'),
]

if settings.DEV_SERVER:  # there is a debug mode for production, but it turns on maintenance mode
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)

    import debug_toolbar  # if we're on the dev server, include urls for debug toolbar
    urlpatterns += [
        path('__debug__/', include(debug_toolbar.urls)),
    ]
Пример #4
0
from django.views.generic import (
    YearArchiveView,
    MonthArchiveView,
    WeekArchiveView,
    DayArchiveView,
    TodayArchiveView,
    DetailView,
    ListView,
)

from blog.models import Post
from blog.views import PostIndexView, PostDetailView

urlpatterns = patterns(
    "",
    url(r"^$", PostIndexView.as_view(), name="blog_post_index"),
    url(
        r"^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$",
        PostDetailView.as_view(),
        name="blog_post_detail",
    ),
    url(
        r"^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/$",
        DayArchiveView.as_view(queryset=Post.objects.live(), date_field="published"),
        name="blog_archive_day",
    ),
    url(
        r"^(?P<year>\d{4})/(?P<month>\w{3})/$",
        MonthArchiveView.as_view(queryset=Post.objects.live(), date_field="published"),
        name="blog_archive_month",
    ),
Пример #5
0
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.sitemaps import GenericSitemap
from django.contrib.sitemaps import views as sitemap_views

from blog.views import PostIndexView

from .sitemaps import StaticViewSitemap, BlogSitemap, IndexSitemap
from .views import AboutView, BlogrollView, ContactView, ContactSuccessView

sitemaps = {
    'home': IndexSitemap,
    'blog': BlogSitemap,
    'static': StaticViewSitemap
}

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^blog/', include('blog.urls')),
    url(r'^about/$', AboutView.as_view(), name='about'),
    url(r'^contact/$', ContactView.as_view(), name='contact'),
    url(r'^blogroll/$', BlogrollView.as_view(), name='blogroll'),
    url(r'^messagereceived/$', ContactSuccessView.as_view(), name='thanks'),
    url(r'^sitemap\.xml$', sitemap_views.index, {'sitemaps': sitemaps}),
    url(r'^sitemap-(?P<section>.+)\.xml$', sitemap_views.sitemap, {'sitemaps': sitemaps}),
    url(r'^captcha/', include('captcha.urls')),
    url(r'^$', PostIndexView.as_view(), name='index'),
]

if settings.DEBUG and not settings.MAINTENANCE_MODE: # there is a debug mode for production, but it turns on maintenance mode
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)