Пример #1
0
# coding: utf-8

from django.conf.urls import url
from django.views.decorators.http import require_POST  # require_GET

from blog.views import PostDetailView, PostsListView, CommentFormView

app_name = 'blog'
urlpatterns = [
    url(r'^$', PostsListView.as_view(), name='post-list'),
    url(r'^post/(?P<pk>\d+)/$', PostDetailView.as_view(), name='post-detail'),
    url(r'^post/comment/$', require_POST(CommentFormView.as_view()),
        name='post-add-comment')
]
Пример #2
0
    TagListView,
    CategoryPostView,
    TagPostView,
    SearchPostView,
    CommentFormView,
    comment_approve,
    comment_remove,
    ReplyFormView,
    reply_approve,
    reply_remove,
)

app_name = 'blog'
urlpatterns = [
    path('search/', SearchPostView.as_view(), name='search_post'),
    path('', IndexView.as_view(), name='index'),
    path('post/<int:pk>/', PostDetailView.as_view(), name='post_detail'),
    path('categories/', CategoryListView.as_view(), name='category_list'),
    path('category/<str:category_slug>/',
         CategoryPostView.as_view(),
         name='category_post'),
    path('tag/<str:tag_slug>/', TagPostView.as_view(), name='tag_post'),
    path('tags/', TagListView.as_view(), name='tag_list'),
    path('comment/<int:pk>/', CommentFormView.as_view(), name='comment_form'),
    path('comment/<int:pk>/approve/', comment_approve, name='comment_approve'),
    path('comment/<int:pk>/remove/', comment_remove, name='comment_remove'),
    path('reply/<int:pk>/', ReplyFormView.as_view(), name='reply_form'),
    path('reply/<int:pk>/approve/', reply_approve, name='reply_approve'),
    path('reply/<int:pk>/remove/', reply_remove, name='reply_remove'),
]
Пример #3
0
router = routers.DefaultRouter()
router.register(r'page', PageViewSet)
router.register(r'post', PostViewSet)
router.register(r'topic', TopicViewSet)
router.register(r'comment', CommentViewSet)


urlpatterns = [
    url(r'^$', IndexView.as_view(), name='home'),
    url(r'^auth/$', AuthView.as_view(), name='auth'),
    url(r'^account/$', AccountFormView.as_view(), name='account'),

    #######API##############
    url(r'^api/login/$', 'authentication.views.login_user'),
    url(r'^api/logout/$', 'authentication.views.logout'),
    url(r'^api/isauth/$', 'authentication.views.isauth'),
    url(r'^registration/$', 'authentication.views.registration'),
    #########################

    url(r'^api/', include(router.urls)),

    #############BLOG####################
    url(r'^api/posts/(?P<topic_id>\d+)$', ToicPostsList.as_view()),
    url(r'^api/comment/(?P<post_id>\d+)$', CommentPostsList.as_view()),
    url(r'^api/comments/form$', CommentFormView.as_view()),
    #####################################
    
    url(r'^admin/', include(admin.site.urls)),
]