Exemple #1
0
"""mysite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from blog.views import PostListView,PostDetailView,NewCommentView,NewBlogPostView,UpdateBlogPostView

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', PostListView.as_view(), name='post-list'),
    url(r'post/(?P<pk>\d+)/$', PostDetailView.as_view(), name='post-details'),
    url(r'new-comment/$', NewCommentView.as_view(), name='new-comment'),
    url(r'post/new/$', NewBlogPostView.as_view(), name='new-blog-post'),
    url(r'post/(?P<pk>\d+)/update/$', UpdateBlogPostView.as_view(), name='update-blog-post'),
]
Exemple #2
0
urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', HomeView.as_view(), name='home'),
    url(r'^new-user/$',
        UserRegistrationView.as_view(),
        name='user_registration'),
    url(r'^login/$', login, {'template_name': 'login.html'}, name='login'),
    url(r'^logout/$', logout, {'next_page': '/login/'}, name='logout'),
    url(r'^blog/new/$', NewBlogView.as_view(), name='new-blog'),
    url(r'^blog/(?P<pk>\d+)/update/$',
        UpdateBlogView.as_view(),
        name='update-blog'),
    url(r'blog/post/new/$', NewBlogPostView.as_view(), name='new-blog-post'),
    url(r'blog/post/(?P<pk>\d+)/update/$',
        UpdateBlogPostView.as_view(),
        name='update-blog-post'),
    url(r'blog/post/(?P<pk>\d+)/$',
        BlogPostDetailsView.as_view(),
        name='blog-post-details'),
    url(r'blog/post/(?P<pk>\d+)/share/$',
        ShareBlogPostView.as_view(),
        name='share-blog-post-with-blog'),
    url(r'blog/post/(?P<post_pk>\d+)/share/to/(?P<blog_pk>\d+)/$',
        SharePostWithBlog.as_view(),
        name='share-post-with-blog'),
    url(r'blog/post/(?P<post_pk>\d+)/stop/share/to/(?P<blog_pk>\d+)/$',
        StopSharingPostWithBlog.as_view(),
        name='stop-sharing-post-with-blog'),
]
from django.contrib.auth.views import LoginView,LogoutView
from django.urls import path, include
from django.views.generic import TemplateView
from accounts.views import UserRegistrationView
from blog.views import (
    HomeView,
    NewBlogView, 
    UpdateBlogView,
    BlogPostDetailView, 
    NewBlogPostView,
    UpdateBlogPostView, 
    ShareBlogPostView,
    SharePostWithBlog,
    StopShareingPostWithBlog,
)
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', HomeView.as_view(),name = 'home'),
    path('new-user/', UserRegistrationView.as_view(), name = 'user_registration'),
    path('login/', LoginView.as_view(template_name = 'login.html'), name = 'login'),
    path('logout/', LogoutView.as_view(next_page = '/login/'), name = 'logout'),
    path('blog/new/', NewBlogView.as_view(), name = 'new_blog'),
    path('blog/<int:pk>/update/', UpdateBlogView.as_view(), name = 'update_blog'),
    path('blog/post/<int:pk>/', BlogPostDetailView.as_view(), name = 'blog_post_details'),
    path('blog/post/new/', NewBlogPostView.as_view(), name = 'new_blog_post'),
    path('blog/post/<int:pk>/update/', UpdateBlogPostView.as_view(), name = 'update_blog_post'),
    path('blog/post/<int:pk>/share/', ShareBlogPostView.as_view(), name = 'share_blog_post'),
    path('blog/post/<int:post_pk>/share/to/<int:blog_pk>/', SharePostWithBlog.as_view(), name = 'share_post_with_blog'),
    path('blog/post/<int:post_pk>/stop/share/to/<int:blog_pk>/', StopShareingPostWithBlog.as_view(), name = 'stop_sharing_post_with_blog'),
]