Пример #1
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf.urls import patterns, url
from django.core.urlresolvers import reverse_lazy
from django.views.generic import RedirectView

from blog.views import PostsListView, PostDetailsView, PostsTagListView, PostsFeed, PostsAtomFeed

urlpatterns = patterns(
    '',
    url(r'^$', PostsListView.as_view(), name="blog"),
    url(r'^feed/', PostsFeed(), name="blog_feed"),
    url(r'^atom/', PostsAtomFeed(), name="blog_atom"),
    url(r'^rss/', RedirectView.as_view(url=reverse_lazy('blog_feed'))),
    url(r'^tag/(?P<slug>.+)/$', PostsTagListView.as_view(), name="posts_tag"),
    url(r'^(?P<slug>.+)/$', PostDetailsView.as_view(), name="post"),
)
Пример #2
0
urlpatterns = patterns(
    '',
    # Index
    url(r'^(?P<page>\d+)?/?$',
        ListView.as_view(
            model=Post,
            paginate_by=5,
        ),
        name='index'),
    # Individual posts
    url(r'^blog/(?P<pub_date__year>\d{4})/(?P<slug>[a-zA-Z0-9-]+)/?$',
        DetailView.as_view(model=Post, ),
        name='post'),
    # Post RSS feed
    url(r'^feed/posts/$', PostsFeed()),
    # Search posts
    url(r'^search', getSearchResults, name='search'),
    #robots.txt
    url(r'^robots.txt$',
        lambda r: HttpResponse(robots_content, content_type="text/plain")),
    #sitemap
    url(r'^sitemap\.xml$',
        sitemap, {'sitemaps': sitemaps},
        name='django.contrib.sitemaps.views.sitemap'),
)
# add flat pages
urlpatterns += patterns(
    'django.contrib.flatpages.views',
    url(r'^about/$', 'flatpage', {'url': '/about/'}, name='about'),
    url(r'^privacy/$', 'flatpage', {'url': '/privacy/'}, name='privacy'),
Пример #3
0
urlpatterns = patterns(
    "",
    # Index
    url(
        r"^(?P<page>\d+)?/?$",
        IndexListView.as_view(),
        name="index",
    ),
    # Individual posts
    url(
        r"^blog/(?P<pub_date__year>\d{4})/(?P<slug>[a-zA-Z0-9-]+)/?$",
        PostDetailView.as_view(),
        name="post",
    ),
    # Post RSS feed
    url(r"^feed/posts/$", PostsFeed()),
    # Search posts
    url(r"^search", get_search_results, name="search"),
    # robots.txt
    url(
        r"^robots.txt$",
        lambda r: HttpResponse(robots_content, content_type="text/plain"),
    ),
    # sitemap
    url(
        r"^sitemap\.xml$",
        sitemap,
        {"sitemaps": sitemaps},
        name="django.contrib.sitemaps.views.sitemap",
    ),
)