from django.urls import path from webapp.views import IndexView, ArticleView, ArticleCreateView, \ ArticleUpdateView, ArticleDeleteView, CommentCreateView, CommentForArticleCreateView, \ CommentListView, CommentUpdateView, CommentDeleteView,ArticleSearchView urlpatterns = [ path('admin/', admin.site.urls), path('', IndexView.as_view(), name='index'), path('article/search/', ArticleSearchView.as_view(), name='article_search'), path('article/<int:pk>/', ArticleView.as_view(), name='article_view'), path('article/add/', ArticleCreateView.as_view(), name='article_add'), path('article/<int:pk>/edit/', ArticleUpdateView.as_view(), name='article_update'), path('article/<int:pk>/delete/', ArticleDeleteView.as_view(), name='article_delete'), path('comments/', CommentListView.as_view(), name='comment_list'), path('comment/add/', CommentCreateView.as_view(), name='comment_add'), path('comment/<int:pk>/edit/', CommentUpdateView.as_view(), name='comment_update'), path('comment/<int:pk>/delete/', CommentDeleteView.as_view(), name='comment_delete'), path('article/<int:pk>/add-comment/', CommentForArticleCreateView.as_view(), name='article_comment_create') ]
https://docs.djangoproject.com/en/2.2/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 webapp.views import IndexView, ArticleView, ArticleCreateView, \ ArticleUpdateView, ArticleDeleteView, CommentCreateView, CommentsView, CommentUpdateView,\ CommentDeleteView urlpatterns = [ path('admin/', admin.site.urls), path('', IndexView.as_view(), name='index'), path('article/<int:pk>/', ArticleView.as_view(), name='article_view'), path('article/add/', ArticleCreateView.as_view(), name='article_add'), path('article/<int:pk>/edit/', ArticleUpdateView.as_view(), name='article_update'), path('article/<int:pk>/delete/', ArticleDeleteView.as_view(), name='article_delete'), path('article/comment', CommentsView.as_view(), name='comments_view'), path('article/comment/add/', CommentCreateView.as_view(), name='comment_add'), path('article/comment/<int:pk>/edit/', CommentUpdateView.as_view(), name='comment_update'), path('article/comment/<int:pk>/delete/', CommentDeleteView.as_view(), name='comment_delete'), ]
app_name = 'webapp' urlpatterns = [ path('', IndexView.as_view(), name='index'), path('article/', include([ path('<int:pk>/', include([ path('', ArticleView.as_view(), name='article_view'), path('update/', ArticleUpdateView.as_view(), name='article_update'), path('delete/', ArticleDeleteView.as_view(), name='article_delete'), path('comments/add/', ArticleCommentCreateView.as_view(), name='article_comment_add'), path('like/', ArticleLikeView.as_view(), name='article_like'), path('unlike/', ArticleUnLikeView.as_view(), name='article_unlike'), ])), path('add/', ArticleCreateView.as_view(), name='article_create'), path('mass-action/', ArticleMassActionView.as_view(), name='article_mass_action'), ])), path('comment/', include([ path('<int:pk>/', include([ path('update/', CommentUpdateView.as_view(), name='comment_update'), path('delete/', CommentDeleteView.as_view(), name='comment_delete'), path('like/', CommentLikeView.as_view(), name='comment_like'), path('unlike/', CommentUnLikeView.as_view(), name='comment_unlike') ])) ])) ]
The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/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 webapp.views import IndexView, ArticleView, ArticleCreateView, ArticleUpdateView, \ ArticleDeleteView, CommentCreateView, CommentView, CommentUpdateView, CommentDeleteView urlpatterns = [ path('admin/', admin.site.urls), path('', IndexView.as_view(), name='index'), path('article/<int:pk>/', ArticleView.as_view(), name='article_view'), path('article/add/', ArticleCreateView.as_view(), name='article_add'), path('article/<int:pk>/edit/', ArticleUpdateView.as_view(), name='article_update'), path('article/<int:pk>/delete/', ArticleDeleteView.as_view(), name='article_delete'), path("comment/all/", CommentView.as_view(), name="comments"), path('comment/add/', CommentCreateView.as_view(), name='comment_add'), path('comment/<int:pk>/edit/', CommentUpdateView.as_view(), name="comment_update"), path('comment/<int:pk>/delete/', CommentDeleteView.as_view(), name="comment_delete") ]
from django.contrib import admin from django.urls import path from webapp.views import IndexView, ArticleView, ArticleCreateView, ArticleUpdateView, \ ArticleDeleteView, CommentView, CommentCreateView, CommentUpdateView, CommentDeleteView, CommentCreateInArticleView,\ ArticleSearchView urlpatterns = [ path('', IndexView.as_view(), name='index'), path('article/<int:pk>/', ArticleView.as_view(), name='article_view'), path('article/add/', ArticleCreateView.as_view(), name='article_add'), path('article/<int:pk>/update/', ArticleUpdateView.as_view(), name='article_update'), path('article/<int:pk>/delete/', ArticleDeleteView.as_view(), name='article_delete'), path('article/search/', ArticleSearchView.as_view(), name='article_search'), path('comments/', CommentView.as_view(), name='comment_index'), path('comment/add/', CommentCreateView.as_view(), name='comment_add'), path('comment/update/<int:pk>', CommentUpdateView.as_view(), name='comment_update'), path('comment/delete/<int:pk>', CommentDeleteView.as_view(), name='comment_delete'), path('comment/add/<int:article_pk>', CommentCreateInArticleView.as_view(), name='comment_create_in_article') ]