Ejemplo n.º 1
0
The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/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'))
"""
# blog/urls.py

from django.urls import path

from blog.views import IndexView, PostDetailView, CategoryListView, TagListView, CategoryPostView, TagPostView, SearchPostView

app_name = 'blog'
urlpatterns = [
    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('tags/', TagListView.as_view(), name='tag_list'),
    path('category/<str:category_slug>/',
         CategoryPostView.as_view(),
         name='category_post'),
    path('tag/<str:tag_slug>/', TagPostView.as_view(), name='tag_post'),
    path('search/', SearchPostView.as_view(), name='search_post'),
]
Ejemplo n.º 2
0
from django.urls import path, re_path
# from blog.views import index
from blog.views import post_details, like_post
from blog.views import category_buttons
# from blog.views import post_form_view
# from blog.views import contactus_view
from blog.views import PostListView, PostFormView, ContactFormView, PostFormUpdateView, PostLatestListView, PostFormDeleteView, SearchPostView

urlpatterns = [
    path('', PostLatestListView.as_view(), name='landing'),
    path('index', PostListView.as_view(), name='index'),
    path('filter/<int:id>', category_buttons, name='category_buttons'),
    path('search', SearchPostView.as_view(), name='search'),
    # path('posts', post_form_view, name='posts'),
    path('posts', PostFormView.as_view(), name='posts'),
    path('update/<slug:slug>',
         PostFormUpdateView.as_view(),
         name='update-view'),
    path('delete/<slug:slug>',
         PostFormDeleteView.as_view(),
         name='delete-view'),
    path('contacts', ContactFormView.as_view(), name='contacts'),
    path('like', like_post, name='like_post'),
    # path('dashboard',dashboard,name='dashboard'),
    path('<str:slug>', post_details, name='post-detail'),
    # path('<slug:slug>', PostDetailView.as_view(), name='post-detail'),
]