from django.urls import path from blog.views import Home, SearchView, CategoryView, PostListView, PostDetailView, PhotoDetailView urlpatterns = [ path('search', SearchView.as_view(), name="search"), path('category/<slug:slug>', CategoryView.as_view(), name="category"), path('', Home.as_view(), name="index"), path('blog', PostListView.as_view(), name="blog"), path('posts/<slug:slug>', PostDetailView.as_view(), name="post-detail"), path('photos/<int:pk>', PhotoDetailView.as_view(), name="photo-detail"), ]
from django.urls import path, include from django.conf.urls import url from . import views from blog.views import PostListView, PostDetailView, PostCreateView, PostDeleteView, PostUpdateView,UserPostListView urlpatterns = [ path('', PostListView.as_view(), name='blog-home'), path('user/<str:username>/', UserPostListView.as_view(), name='user-posts'), path('post/<int:pk>/', PostDetailView.as_view(), name='post-detail'), path('post/<int:pk>/update/', PostUpdateView.as_view(), name='post-update'), path('post/<int:pk>/delete/', PostDeleteView.as_view(), name='post-delete'), path('post/new/', PostCreateView.as_view(), name='post-create'), path('about/', views.about, name='blog-about'), ]
1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ import xadmin from django.contrib import admin from django.urls import path from django.conf.urls import url, include from django.conf import settings from django.conf.urls.static import static from blog.views import IndexView, CategoryView, TagView, PostDetailView, SearchView, AuthorView from config.views import LinkListView from comment.views import CommentView from .custom_site import custom_site from .autocomplete import CategoryAutoComplete, TagAutoComplete urlpatterns = [ url(r'^$', IndexView.as_view(), name='index'), url(r'^search/$', SearchView.as_view(), name='search'), url(r'^category/(?P<category_id>\d+)/$', CategoryView.as_view(), name='category-list'), url(r'^tag/(?P<tag_id>\d+)/$', TagView.as_view(), name='tag-list'), url(r'^post/(?P<post_id>\d+).html$', PostDetailView.as_view(), name='post-detail'), url(r'^author/(?P<owner_id>\d+).html$', AuthorView.as_view(), name='author'), url(r'^links/$', LinkListView.as_view(), name='links'), url(r'^comment/$', CommentView.as_view(), name='comment'), url(r'^super_admin/', admin.site.urls, name='super-admin'), # url(r'^admin/', custom_site.urls, name='admin'), url(r'^admin/', xadmin.site.urls, name='xadmin'), url(r'^category-autocomplete/$', CategoryAutoComplete.as_view(), name='category-autocomplete'), url(r'^tag-autocomplete/$', TagAutoComplete.as_view(), name='tag-autocomplete'), url(r'^ckeditor/', include('ckeditor_uploader.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
router = DefaultRouter() router.register(r'post', PostViewSet, basename='api-post') router.register(r'category', CategoryViewSet, basename='api-category') urlpatterns = [ path('super_admin/', admin.site.urls, name='super-admin'), path('admin/', custom_site.urls, name='admin'), path('xadmin/', xadmin.site.urls, name='xadmin'), path('ckeditor/', include('ckeditor_uploader.urls')), path('api/', include(router.urls)), path('api/docs/', include_docs_urls(title='typeidea apis')), re_path(r'^$', cache_page(60 * 20, key_prefix='sitemap_cache_')(IndexView.as_view()), name='index'), re_path(r'^category/(?P<category_id>\d+)/$', CategoryView.as_view(), name='category-list'), re_path(r'^tag/(?P<tag_id>\d+)/$', TagView.as_view(), name='tag-list'), re_path(r'^post/(?P<post_id>\d+)/$', PostDetailView.as_view(), name='post-detail'), re_path(r'^links/$', LinkListView.as_view(), name='links'), re_path(r'^comment/$', CommentView.as_view(), name='comment'), re_path(r'^search/$', SearchView.as_view(), name='search'), re_path(r'^author/(?P<owner_id>\d+)/$', AuthorView.as_view(), name='author'), re_path(r'^rss|feed$', LatestPostFeed(), name='rss'), re_path(r'^sitemap\.xml$', cache_page(60 * 20, key_prefix='sitemap_cache_')(sitemap_views.sitemap), {'sitemaps': {'posts': PostSiteMap}}), re_path(r'^category-autocomplete/$', CategoryAutocompleteView.as_view(), name='category-autocomplete'), re_path(r'^tag-autocomplete/$', TagAutocompleteView.as_view(), name='tag-autocomplete'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: import debug_toolbar
from blog.views import (PostListView, PostDetailView, PostYearArchiveView, PostListByTag) urlpatterns = patterns('', # Index view url(r'^$', PostListView.as_view(), name='blog', ), # Detail view url(r'^(?P<pub_year>\d{4})/(?P<pub_month>\w{3})/(?P<slug>[a-zA-Z0-9-]+)/$', PostDetailView.as_view(), name='blog-detail', ), # Yearly archive view url(r'^(?P<year>\d{4})/$', PostYearArchiveView.as_view(), name='blogarchive' ), # Category view url(r'^tags/(?P<tags>\w*)/$', PostListByTag.as_view(), name='blogtags', ), )
from django.contrib import admin from django.conf import settings from django.urls import path, include, re_path from django.conf.urls.static import static from blog.views import PostListView, PostByCategoryListView, PostDetailView # from blog.models import StaticPage app_name='blog' urlpatterns = [ path('', PostListView.as_view(), name='posts_list'), # path('category/<slug>', PostByCategoryListView.as_view(), name='posts_by_category_list'), re_path(r'^category/(?P<slug>(.*))/$', PostByCategoryListView.as_view(), name='posts_by_category_list'), path('<int:year>/<int:month>/<int:day>/<slug:slug>', PostDetailView.as_view(), name='posts_detail'), path('posts/<pk>', PostDetailView.as_view(), name='posts_detail_by_id'), # path('api/', include('blog.api.urls')), ]
"""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'), ]
""" blog.urls ========= """ from django.conf.urls import patterns, url from blog.views import PostListView, PostDetailView urlpatterns = patterns('', url(r'^', PostListView.as_view(), name="list"), url(r'^/(?P<slug>[\w-]+)/$', PostDetailView.as_view(), name="detail"), )
from django.conf.urls import include, url from blog.views import PostListView, PostDetailView urlpatterns = [url(r"^$", PostListView.as_view(), name="list"), url(r"^(?P<pk>\d+)/$", PostDetailView.as_view())]
#coding: utf-8 from django.conf.urls import patterns, url from blog.views import PostsListView, PostDetailView urlpatterns = patterns('', url(r'^$', PostsListView.as_view(), name='list'), #url(r'^(?P<pk>\d+)/$', PostDetailView.as_view()), url(r'^(?P<slug>[-\w]+)',PostDetailView.as_view(),name='view1'), )
from django.conf.urls import url, include from blog.views import PostListView, PostDetailView, CategoryDetailView, CategoryListView, PostCreateView, \ CategoryCreateView __author__ = 'k1' urlpatterns = [ url(r'^$', PostListView.as_view(), name='post_list'), url(r'^post/(?P<pk>\d+)/$', PostDetailView.as_view(), name='post_detail'), url(r'^post/create/$', PostCreateView.as_view(), name='post_create'), # url(r'^comments/', include('django.contrib.comments.urls')), url(r'^categories/$', CategoryListView.as_view(), name='category_list'), url(r'^category/(?P<pk>\d+)/$', CategoryDetailView.as_view(), name='category_detail'), url(r'^category/create/$', CategoryCreateView.as_view(), name='category_create'), ]
url(r'^shop/orders/$', NewOrderView.as_view(template_name='order.html')), url(r'^home/$', HomePageView.as_view()), url(r'^blog/$', BlogPostListView.as_view()), url(r'^blog/page(?P<page>[0-9]+)/$', BlogPostListView.as_view()), url(r'^blog/(?P<pk>\d+)$', BlogPostDetailView.as_view()), url(r'^purchase/$', SinglePageView.as_view(template_name='singlepage.html', kw='purchase')), url(r'^thanks/$', SinglePageView.as_view(template_name='singlepage.html', kw='thanks')), url(r'^fail/$', SinglePageView.as_view(template_name='singlepage.html', kw='fail')), url(r'^blog/tag/(?P<tag>\D+)/$', BlogPostTagListView.as_view(template_name='blogpost_list.html')), url(r'^blog/posts/(?P<pk>\d+)/$', BlogPostDetailView.as_view(template_name='blogpost_detail.html')), url(r'^photoalbum/$', PhotoAlbumView.as_view()), url(r'^photoalbum/tag/(?P<tag>\D+)/$', PhotoAlbumTagView.as_view()), url(r'^gallery/', include('photologue.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^(?P<slug>\w+)/page/$', SinglePageSidebarView.as_view()), url(r'^(?P<cat>\w+)/(?P<pk>\d+)$', PostDetailView.as_view()), #url(r'^\w+/(?P<pk>\d+)/$', PostDetailView.as_view()), url(r'^(?P<cat>\S+)/list/$', PostListView.as_view(template_name='newpost_list.html')), url(r'^(?P<cat>\S+)/poems/$', PostListView.as_view(template_name='poetry_list.html', paginate_by=12)), url(r'^(?P<cat>\S+)/list/page(?P<page>[0-9]+)/$', PostListView.as_view(template_name='newpost_list.html')), url(r'^(?P<cat>\S+)/poems/page(?P<page>[0-9]+)/$', PostListView.as_view(template_name='poetry_list.html')), url(r'^(?P<cat>\w+)/$', CatListView.as_view(template_name='cat_list.html', paginate_by=4)), url(r'^(?P<cat>\S+)/page(?P<page>[0-9]+)/$', PostListView.as_view(template_name='cat_list.html')), url(r'^gallery/photo/(?P<id>\S+)/buy/(?P<item>\w+)/$', OrderFormView.as_view(template_name='photo_buy.html'), name='buy'), url(r'^gallery/photo/(?P<id>\S+)/buy/(?P<item>\w+)/success/$', OrderView.as_view(template_name='photo_buy_success.html'), name='buy-success'), url(r'^grappelli/', include('grappelli.urls')), )
""" blog.urls ========= """ from django.conf.urls import patterns, url from blog.views import PostListView, PostDetailView, PostCreateView urlpatterns = patterns('', #url(r'^$', PostListView.as_view(), name="list"), url(r'^post/new', PostCreateView.as_view(), name="create"), url(r'^post/(?P<slug>[/\w-]+)', PostDetailView.as_view(), name="detail"), )
from django.conf.urls.defaults import * from blog.views import PostListView, PostDetailView urlpatterns = patterns( "", url(r"^$", PostListView.as_view(), name="post_list"), url(r"^(?P<year>\d{4})/(?P<slug>.+)/$", PostDetailView.as_view(), name="post_detail"), )
from django.urls import path ,re_path from blog.views import index from blog.views import post_details,contact_view,post_form_view,post_edit_form_view,PostListView,PostDetailView,PostFormView,ContactFormView,PostFormUpdateView urlpatterns = [ # path('',index), path('',PostListView.as_view()), # path("<int:id>",post_details), # path("<int:pk>",PostDetailView.as_view()), path("posts",PostFormView.as_view()), path("posts/<slug:slug>",PostFormUpdateView.as_view()), path("contact",ContactFormView.as_view()), path("<slug:slug>",PostDetailView.as_view(),name ="post-detail"), # path("contact",contact_view), # path("posts",post_form_view), ] # "post-detail" => "<slug:slug>" # url "post-detail" "abc" = "/abc" => valid url # a= 10 # print(a) # post-detail = "post/<slug:slug>"" # {% url 'url_name' args %}
# -*- coding: utf-8 -*- from django.conf.urls import patterns, url from blog.views import PostsListView, PostDetailView urlpatterns = patterns( "", url(r"^$", PostsListView.as_view(), name="list"), url(r"^(?P<pk>\d+)/$", PostDetailView.as_view()) )
from django.conf.urls import patterns, include, url from blog.views import PostDetailView, PostSummaryView, PostListView, PostCreateView urlpatterns = patterns('blog.views', url(r'^$', PostListView.as_view()), url(r'^all/$', PostSummaryView.as_view()), url(r'^new/$', 'edit_post'), url(r'^(?P<slug>[\w\-]+)/$', PostDetailView.as_view()), url(r'^(?P<slug>[\w\-]+)/edit/$', 'edit_post'), )
urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', HomeListView.as_view(),name="home-list"), url(r'^hakkimda/', AboutTemplateView.as_view(), name="about"), url(r'^iletisim/', ContactView.as_view(), name="about"), url(r'^blog/', BlogListView.as_view(), name="about"), url(r'^kategori/(?P<slug>[-\w]+)/', CategoryView.as_view(), name='list-detail'), url(r'^etiket/(?P<slug>[-\w]+)/$', TagsView.as_view(), name='tags'), url(r'^sitemap_post\.xml$', sitemap,{'sitemaps': {'blog': GenericSitemap(post_dict, priority=0.6)}}, name='django.contrib.sitemaps.views.sitemap'), url(r'^sitemap_category\.xml$', sitemap,{'sitemaps': {'blog': GenericSitemap(category_dict, priority=0.6)}}, name='django.contrib.sitemaps.views.sitemap'), url(r'^sitemap_tags\.xml$', sitemap, {'sitemaps': {'blog': GenericSitemap(tags_dict, priority=0.6)}}, name='django.contrib.sitemaps.views.sitemap'), url(r'^robots.txt/', RobotsView.as_view(), name="robots"), url(r'^ckeditor/', include('ckeditor_uploader.urls')), url(r'^feed/$', LatestEntriesFeed()), url(r'^(?P<slug>[-\w]+)/$', PostDetailView.as_view(), name='post'), ] urlpatterns += [ url(r'^media/(?P<path>.*)$', serve, { 'document_root': settings.MEDIA_ROOT, }), ]
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.conf.urls import url from blog.views import IndexView, PostDetailView, CategoryDetailView from blog.views import PostDayArchiveView, PostMonthArchiveView, \ PostYearArchiveView urlpatterns = [ url(r'^$', IndexView.as_view(), name='index'), url(r'^(?P<year>\d{4})/' r'(?P<month>\d{1,2})/' r'(?P<day>\d{1,2})/' r'(?P<slug>[-\w]+)/$', view=PostDetailView.as_view(), name='detail'), url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', view=PostDayArchiveView.as_view(), name='day'), url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', view=PostMonthArchiveView.as_view(), name='month'), url(r'^(?P<year>\d{4})/$', view=PostYearArchiveView.as_view(), name='year'), url(r'^categories/(?P<slug>[-\w]+)/$', view=CategoryDetailView.as_view(), name='category'), ]
from blog.views import PostDetailView, PostDeleteView from django.contrib.auth.decorators import login_required # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', # Examples: url(r'^$', 'blog.views.posts_index'), url(r'^post/new/', 'blog.views.post_new', name="post_new"), url(r'^post/create/', 'blog.views.post_create'), url(r'^posts/', 'blog.views.posts_index'), url(r'^post/(?P<slug>[-\w]+)/$', PostDetailView.as_view(), name='post-detail'), url(r'^post/delete/(?P<slug>[-\w]+)/$', login_required(PostDeleteView.as_view())), url(r'^post/edit/(?P<slug>[-\w]+)/$','blog.views.post_edit'), url(r'^post/edited/(?P<slug>[-\w]+)/$','blog.views.post_edited'), url(r'^comment/create/', 'blog.views.comment_create'), url(r'^comment/delete/', 'blog.views.comment_delete'), url(r'^tag/new/', 'blog.views.tag_new'), url(r'^tag/create/', 'blog.views.tag_create'), url(r'^tag/(?P<slug>[-\w]+)/$','blog.views.tag_detail'), url(r'^login/', 'blog.views.login_view'), url(r'^logout/', 'blog.views.logout_view'), url(r'^accounts/auth/', 'blog.views.auth_view') )
# -*- coding: utf-8 -*- from django.conf.urls import url from blog.views import PostsListView, PostDetailView from django.views.decorators.cache import cache_page urlpatterns = [ url(r'^$', cache_page(60 * 15)(PostsListView.as_view()), name='Postlist'), url(r'^(?P<pk>\d+)/$', cache_page(60 * 15)(PostDetailView.as_view()), name='Detallist'), ]
#coding: utf-8 from django.conf.urls import url from blog.views import PostListView, PostDetailView,PostCreateView urlpatterns = [ url(r'^$', PostListView.as_view(), name='list'), url(r'^(?P<pk>\d+)/$', PostDetailView.as_view(),name='detail'), url(r'^create/$', PostCreateView.as_view(),name='create'), ]
from django.conf.urls import url from blog.views import ( AboutView, CreatePostView, DraftListView, PostDetailView, PostDeleteView, PostListView, PostUpdateView, ) urlpatterns = [ url(r"^$", PostListView.as_view(), name="post_list"), url(r"^about/$", AboutView.as_view(), name="about"), url(r"^post/(?P<pk>\d+)$", PostDetailView.as_view(), name="post_detail"), url(r"^post/new/$", CreatePostView.as_view(), name="post_new"), url(r"^post/(?P<pk>\d+)/edit/$", PostUpdateView.as_view(), name="post_edit"), url(r"^post/(?P<pk>\d+)/remove/$", PostDeleteView.as_view(), name="post_remove"), url(r"^drafts/$", DraftListView.as_view(), name="post_drafts_list"), ]
from django.conf.urls.defaults import patterns, include, url from django.views.generic import ListView, DetailView from blog.models import Post from blog.views import PostDetailView from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^$', ListView.as_view( queryset=Post.objects.all(), context_object_name="posts_list"), name="home" ), url(r'^post/(?P<slug>[a-zA-Z0-9-]+)/$', PostDetailView.as_view( queryset=Post.objects.all(), context_object_name="post"), name="post" ), url(r'^admin/', include(admin.site.urls)), )
from django.urls import path from . import views from blog.views import PostListView, PostDetailView, PostCreateView, PostUpdateView, PostDeleteView, UserPostListView urlpatterns = [ path('', PostListView.as_view(), name='blog-home'), # person_changelist path('user/<str:username>', UserPostListView.as_view(), name='user-posts'), path('post/<int:pk>/', PostDetailView.as_view(template_name='blog/post_detail.html'), name='post-detail'), path('post/new/', PostCreateView.as_view(template_name='blog/post_form.html'), name='post-create'), # person_add path('post/<int:pk>/update', PostUpdateView.as_view(), name='post-update'), path('post/<int:pk>/delete', PostDeleteView.as_view(template_name='blog/post_confirm_delete.html'), name='post-delete'), path('search', views.search, name='search'), path('ajax/load-cities/', views.load_cities, name='ajax_load_cities'), path('ajax/load-states/', views.load_states, name='ajax_load_states'), path('contact/', views.contact, name='contact'), ]
from django.conf.urls import patterns, url from blog.views import PostListView, PostDetailView urlpatterns = patterns('', url(r'^$', PostListView.as_view(), name='list'), url(r'^(?P<slug>[\w-]+)$', PostDetailView.as_view(), name='detail'), )
#coding: utf-8 from django.conf.urls import patterns, url from blog.views import PostsListView, PostDetailView urlpatterns = patterns('', url(r'^$', PostsListView.as_view(), name='list'), # то есть по URL http://имя_сайта/blog/ # будет выводиться список постов url(r'^(?P<pk>\d+)/$', PostDetailView.as_view()), # а по URL http://имя_сайта/blog/число/ # будет выводиться пост с определенным номером )
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, re_path from blog.views import (IndexView, CategoryView, TagView, PostDetailView, SearchView, AuthorView) from comment.views import CommentView from config.views import links, LinkListView from typeidea.custom_site import custom_site urlpatterns = [ path('', IndexView.as_view(), name='index'), path('detail/', PostDetailView.as_view(), name='post-detail'), re_path('post/(?P<post_id>\d+).html', PostDetailView.as_view(), name='post-detail'), re_path('tag/(?P<tag_id>\d+)', TagView.as_view(), name='tag-list'), re_path('category/(?P<category_id>\d+)', CategoryView.as_view(), name='category-list'), path('links/', LinkListView.as_view(), name='links'), path('search/', SearchView.as_view(), name='search'), path('comment/', CommentView.as_view(), name='comment'), re_path('author/(?P<owner_id>\d+)/', AuthorView.as_view(), name='author'), path('super_admin/', admin.site.urls, name='super-admin'), path('admin/', custom_site.urls, name='admin'), ]
from django.conf.urls import patterns, include, url from blog.views import PostDetailView, PostListView urlpatterns = patterns('', url(r'^posts/$', PostListView.as_view(), name="post_list_view"), url(r'^posts/(?P<slug>[-\w]+)/$', PostDetailView.as_view(), name="post_detail"), )
from django.conf.urls import include, url from blog.views import PostListView, PostDetailView urlpatterns = [ url(r'^$', PostListView.as_view(), name="list"), url(r'^(?P<pk>\d+)/$', PostDetailView.as_view()), ]
# -*- coding: utf-8 -*- from django.conf.urls import * from blog.views import (PostsListView, PostDetailView, submit_ajax, submit, delete_all_objects, search_posts) urlpatterns = [ url(r'search_posts/',search_posts), url(r'delete_all_objects/',delete_all_objects), url(r'form_submit', submit), url(r'submit/',submit_ajax), url(r'^$',PostsListView.as_view(),name='list'), # вывод списка постов url(r'^(?P<pk>\d+)/$', PostDetailView.as_view()), # вывод поста с определенным номером ]
from django.conf.urls import url from blog.views import PostListView,PostCreateView,PostUpdateDeleteView, \ PostDetailView,CommentView,TagView urlpatterns = [ url(r'^view/?$', PostListView.as_view(), name='view-all'), #GET url(r'^create/?$', PostCreateView.as_view(), name='create-post'), #POST url(r'^(?P<pk>\d+)$', PostDetailView.as_view(), name='view-one'), #GET url(r'^(?P<pk>\d+)/update$', PostUpdateDeleteView.as_view(), name='update-post'), #PUT url(r'^(?P<pk>\d+)/delete$', PostUpdateDeleteView.as_view(), name='delete-post'), #DELETE url(r'^(?P<pk>\d+)/comment$', CommentView.as_view(), name='comment-on-post'), #POST url(r'^(?P<pk>\d+)/vote', PostUpdateDeleteView.as_view(), name='vote-post'), #PATCH url(r'^tag$', TagView.as_view(), name='list-tag'), #GET ]
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, re_path from django.conf import settings from django.conf.urls.static import static from blog.views import PostListView, model_form_upload, PostDetailView, CategoryListView urlpatterns = [ path('admin/', admin.site.urls), re_path(r'^$', PostListView.as_view(), name='home'), re_path(r'^(?P<pk>[\d]+)/$', PostDetailView.as_view(), name='detail'), re_path(r'^(?P<category>[-\w]+)/$', CategoryListView.as_view(), name='category'), re_path(r'^uploads/form/$', model_form_upload, name='model_form_upload'), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
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. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ import xadmin xadmin.autodiscover() from xadmin.plugins import xversion from django.conf.urls import url from django.contrib import admin from comment.views import CommentView from blog.views import PostDetailView, IndexView, TagView, CategoryView from config.views import LinkView from typeidea import adminx urlpatterns = [ url(r'^$', IndexView.as_view(), name='index'), url(r'^tag/(?P<tag_id>\d+)/$', TagView.as_view(), name='tag'), url(r'^category/(?P<category_id>\d+)/$', CategoryView.as_view(), name='category'), url(r'^post/(?P<post_id>\d+)/$', PostDetailView.as_view(), name='detail'), url(r'^admin/', xadmin.site.urls), url(r'^links/', LinkView.as_view(), name='link'), url(r'^comment/', CommentView.as_view(), name='comment'), ]
from django.contrib import admin from django.urls import path, include from django.conf.urls.static import static from django.conf import settings from pages.views import AboutView, ContactUsView, HomeView, ProjectView, ServiceView, ContactView from blog.views import PostListView, PostDetailView from rest_framework import routers, serializers, viewsets from rest01.views import (PostList, PostDetail, CreatePost, UpdatePost, DeletePost) urlpatterns = [ path('batmans-admin/', admin.site.urls), ### PAGES APP URLS ### path('', HomeView.as_view(), name='home'), path('about_us/', AboutView.as_view(), name='about'), path('what_we_do/', ServiceView.as_view(), name='service'), path('completed_projects/', ProjectView.as_view(), name='project'), path('contact_us/', ContactUsView.as_view(), name='contact'), #### BLOG URLS ### path('blog', PostListView.as_view(), name='list'), path('post/<slug>/<pk>/', PostDetailView.as_view(), name='post-detail'), path('post/', PostList.as_view(), name='post-list'), path('post/<slug>/<pk>/', PostDetail.as_view(), name='post-detail'), path('post/create', CreatePost.as_view(), name='create-post'), path('post/<pk>/update', UpdatePost.as_view(), name='update-post'), path('post/<pk>/delete', DeletePost.as_view(), name='delete-post'), ## OTHER BASE URLS FOR DEPENDENCIES ##### path('ckeditor/', include('ckeditor_uploader.urls')), path('api-auth/', include('rest_framework.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from settings import MEDIA_ROOT from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() from blog.views import PostsView, PostDetailView, EditPostView, CreatePostView, LoginView urlpatterns = patterns('', url(r"^admin/doc/", include("django.contrib.admindocs.urls")), url(r"^admin/", include(admin.site.urls)), url(r"^static/(?P<path>.*)$", "django.views.static.serve", { "document_root": MEDIA_ROOT }), url(r"^$", PostsView.as_view(), name='main'), url(r"^post/(?P<slug>[-\w]+)/$", PostDetailView.as_view(), name='post'), url(r"^update/(?P<slug>[-\w]+)/$", EditPostView.as_view(), name='update'), url(r"^create/$", CreatePostView.as_view(), name='create'), url(r'^login/$', LoginView.as_view(), name="login"), )
from django.views.decorators.cache import cache_page # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() from blog.views import (IndexView, CategoryListView, TagsListView, PostDetailView, PageDetailView) from feeds import LatestEntriesFeed from sitemap import PostSitemap urlpatterns = patterns('', url(r'^$', IndexView.as_view(), name='home'), url(r'^feed|rss/$', LatestEntriesFeed()), url(r'^sitemap\.xml$', cache_page(sitemap_views.sitemap, 60 * 60 * 12), {'sitemaps': {'posts': PostSitemap}}), url(r'^category/(?P<alias>\w+)/', CategoryListView.as_view()), url(r'^tag/(?P<tag>[\w|\.|\-]+)/$', TagsListView.as_view()), url(r'^admin/', include(admin.site.urls), name='admin'), url(r'^xmlrpc/$', 'django_xmlrpc.views.handle_xmlrpc', {}, 'xmlrpc'), #放到最后 url(r'^(?P<slug>[\w|\-|\d|\W]+?).html$', PostDetailView.as_view()), url(r'^(?P<slug>\w+)/$', PageDetailView.as_view()), ) urlpatterns += staticfiles_urlpatterns()
from django.conf.urls import patterns, url from blog.views import PostsListView, PostDetailView urlpatterns = patterns( "", url(r"^$", PostsListView.as_view(), name="list"), # http://name/blog/ url(r"^(?P<pk>\d+)/$", PostDetailView.as_view()), # URL http://name/blog/{some number}/ <= post with defined number )
from django.conf.urls import url, include from blog.views import PostListView from blog.views import PostDetailView from blog.views import PostCommentView urlpatterns = [ url(r'^$', PostListView.as_view(), name='post-list'), url(r'^(?P<pk>\d+)/$', PostDetailView.as_view(), name='post-detail'), url(r'^(?P<pk>\d+)/comment/$', PostCommentView, name='postcomment'), ]
from django.conf.urls import include, url from django.contrib import admin from django.conf.urls.static import static from django.conf import settings from blog.views import PostCreateView, PostDetailView, PostUpdateView, PostDeleteView, index from gallery.views import PhotoCreateView, PhotoListView # AjaxPhotoUploadView, url(r'^(?P<pk>\d+)/ajax-upload/$', AjaxPhotoUploadView.as_view(), name='ajax_photo_upload_view',), urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^$', index, name='list'), url(r'^create/$', login_required(PostCreateView.as_view()), name='create'), url(r'^detail/(?P<pk>[0-9]+)/$', PostDetailView.as_view(), name='detail'), url(r'^update/(?P<pk>[0-9]+)/$', login_required(PostUpdateView.as_view()), name='update'), url(r'^delete/(?P<pk>[0-9]+)/$', login_required(PostDeleteView.as_view()), name='delete'), url(r'^photo_create/$', login_required(PhotoCreateView.as_view()), name='photo-create'), url(r'^photo_list/$', PhotoListView.as_view(), name='photo-list'), url(r'^login/$', 'django.contrib.auth.views.login'), url(r'^logout/$', 'django.contrib.auth.views.logout'), url(r'^tinymce/', include('tinymce.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.urls import path, include from blog.views import PostListView, PostDetailView app_name = 'blog' urlpatterns = [ path('<slug:slug>/', PostDetailView.as_view(), name='detail'), path('', PostListView.as_view(), name='post_list'), ]
from django.conf.urls import url from blog.views import PostListView, PostListViewByTags, PostDetailView urlpatterns = [ url(r'^$', PostListView.as_view(), name='home'), url(r'^(?P<slug>[-_\w]+)', PostDetailView.as_view(), name='post_detail') ]
from django.contrib import admin from django.conf import settings from django.conf.urls import patterns, include, url import fancypages.urls from fancypages import views from blog.views import PostDetailView, PostListView admin.autodiscover() urlpatterns = patterns( '', url(r'^$', views.HomeView.as_view(), name='home'), url(r'^posts/$', PostListView.as_view(), name="post-list"), url(r'^posts/(?P<slug>[\w-]+)/$', PostDetailView.as_view(), name="post-detail"), url(r'^admin/', include(admin.site.urls)), url(r'^', include(fancypages.urls)), ) if settings.DEBUG: urlpatterns += patterns( '', url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))
from django.urls import path from blog.views import blog, PostDetailView, search, PostBlogView, UpdateBlogView, DeleteBlogView # app_name = 'blog' urlpatterns = [ path( 'post_blog_page/', PostBlogView.as_view(), name='post_blog_page' ), path( 'post_blog_page/update/<int:pk>', UpdateBlogView.as_view(), name='update_blog_page' ), path( 'post_blog_page/delete/<int:pk>', DeleteBlogView.as_view(), name='delete_blog_page' ), path( '<slug>/', PostDetailView.as_view(), name='post' ), path( 'q', search, name='search' ), ]
#coding: utf-8 from django.conf.urls import * from blog.views import PostsListView, PostDetailView, category urlpatterns = [ url(r'^$', PostsListView.as_view(), name='list'), # то есть по URL http://имя_сайта/blog/ # будет выводиться список постов url(r'^(?P<pk>\d+)/$', PostDetailView.as_view(), name=''), # а по URL http://имя_сайта/blog/число/ # будет выводиться пост с определенным номером url(r'^category/(?P<slug>[-\w]+)/$', category, name='category'), ]
from blog.views import PostListView, PostDetailView from galleries.views import GalleryListView, GalleryDetailView from art.views import ArtworkDetailView from tags.views import TagListView, TagDetailView from .views import HomepageView admin.autodiscover() urlpatterns = patterns('', url(r'^$', HomepageView.as_view(), name='index'), # Exhibition Views url(r'^exhibitions/$', ExhibitionListView.as_view(), name="exhib_list"), url(r'^exhibitions/(?P<slug>[-\w]+)/$', ExhibitionDetailView.as_view(), name="exhib_detail"), # Blog Views url(r'^journey/$', PostListView.as_view(), name="blog_list"), url(r'^journey/(?P<slug>[-\w]+)/$', PostDetailView.as_view(), name="blog_detail"), # Gallery Views url(r'^galleries/$', GalleryListView.as_view(), name="gal_list"), url(r'^galleries/(?P<slug>[-\w]+)/$', GalleryDetailView.as_view(), name="gal_detail"), url(r'^galleries/artwork/(?P<slug>[-\w]+)/$', ArtworkDetailView.as_view(), name="art_detail"), # TinyMCE url(r'^tinymce/', include('tinymce.urls')), # Media url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT,}), # Admin url(r'^admin/', include(admin.site.urls)), url(r'^admin_tools/', include('admin_tools.urls')), )
from django.urls import path, include from rest_framework.routers import DefaultRouter from blog.api import PostListViewSet, PostViewSet from blog.views import HomeView, NewPostView, BlogView, PostDetailView router = DefaultRouter() router.register('posts', PostViewSet, basename='posts') urlpatterns = [ path('', HomeView.as_view(), name='home'), path('new-post', NewPostView.as_view(), name='new_post'), path('blogs/<pk>', BlogView.as_view(), name='blog'), path('blogs/<username>/<int:pk>', PostDetailView.as_view(), name='post_detail'), path('api/1.0/', include(router.urls), name='post_api'), path('api/1.0/blog/<int:user>/', PostListViewSet.as_view({'get': 'list'}), name='post_list_api') ]
#coding: utf-8 from django.conf.urls import patterns, include, url from django.conf.urls.static import static from django.conf import settings from django.contrib import admin admin.autodiscover() from blog.views import IndexView, CategoryListView, PostDetailView urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'^$', IndexView.as_view(), name='home'), url(r'^category/(?P<slug>[-_\w]+)/$', CategoryListView.as_view(), name='category_list'), url(r'^article/(?P<slug>[-_\w]+)/$', PostDetailView.as_view(), name='post_detail'), ) urlpatterns += patterns('blog.views', # url(r'^validate_input/$', 'validate_input'), url(r'^upload/$', 'upload'), url(r'^create_album/$', 'create_album'), ) # + static(r'^register/(?P<path>.*)$', document_root=settings.SITEPAGE_ROOT) urlpatterns += patterns('', url(r'^register/(?P<path>.*)$','django.views.static.serve',\ {'document_root': settings.SITEPAGE_ROOT}), )
from django.urls import path from blog.views import PostListView, PostDetailView, contact_us_form_view, PostCreateView, PostUpdateView, PostDeleteView, profileDetailView, BookmarkView, CommentDeleteView, bookmarkDeleteView, PostSearchListView urlpatterns = [ path('', PostListView.as_view(), name='home'), # path('blog', blogList), path('blogs/<slug:slug>', PostDetailView.as_view(), name='post-detail'), path('contactUs/', contact_us_form_view, name='contactUs'), path('category/<int:id>/', PostListView.as_view(), name='post_by_category'), path('post/', PostCreateView.as_view(), name='post'), path('update/<slug:slug>/', PostUpdateView.as_view(), name='update'), path('delete/<slug:slug>/', PostDeleteView.as_view(), name='delete'), path('<int:pk>/', profileDetailView.as_view(), name='profile'), path('search/', PostSearchListView.as_view(), name='search'), path('blog/bookmark', BookmarkView.as_view(), name='bookmark'), path('blog/<int:pk>/add_bookmark', BookmarkView.as_view(), name='add-bookmark'), path('comment/<int:id>/', CommentDeleteView, name='commentDelete'), path('bookmark/<int:id>/', bookmarkDeleteView, name='bookmarkDelete') ]
from django.urls import path from django.conf.urls import url from blog import views from blog.views import(AboutView,PostListView,PostDetailView, CreatePostView,UpdatePostView,PostDeleteView,DraftListView, add_comment_to_post,comment_approve,comment_remove,post_publish) urlpatterns = [ path('',PostListView.as_view(),name="post_list"), path('about/',AboutView.as_view(),name="about"), url('post/(?P<pk>\d+)$',PostDetailView.as_view(),name="post_detail"), url('post/new/$',CreatePostView.as_view(),name="post_new"), url('post/(?P<pk>\d+)/edit/$',UpdatePostView.as_view(),name="post_edit"), url('post/(?P<pk>\d+)/remove/$',PostDeleteView.as_view(),name="post_remove"), url('drafts/',DraftListView.as_view(),name="post_draft_list"), url('post/(?P<pk>\d+)/comment/$',add_comment_to_post,name="add_comment_to_post"), url('comment/(?P<pk>\d+)/approve/$',comment_approve,name="comment_approve"), url('comment/(?P<pk>\d+)/remove/$',comment_remove,name="comment_remove"), url('post/(?P<pk>\d+)/publish/$',post_publish,name="post_publish"), ]
Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url from django.contrib import admin from .custom_site import custom_site from blog.views import post_list, post_detail from config.views import links from blog.views import PostDetailView from blog.views import (IndexView, CategoryView, TagView, PostDetailView) urlpatterns = [ # url(r"^$",post_list,name="tag_list"), url(r"^$", IndexView.as_view(), name="index"), # url(r"^category/(?P<category_id>\d+)/$",post_list,name="category_list"), url(r"^category/(?P<category_id>\d+)/$", CategoryView.as_view(), name="category_list"), # url(r"^tag/(?P<tag_id>\d+)/$",post_list,name="tag_list"), url(r"^tag/(?P<tag_id>\d+)/$", TagView.as_view(), name="tag_list"), # url(r"^post/(?P<post_id>\d+).html/$",post_detail,name="post_detail"), url(r"^post/(?P<pk>\d+).html/$", PostDetailView.as_view(), name="post_detail"), url(r"^links/$", links, name="links"), url(r'^admin/', admin.site.urls, name="admin"), url(r'^super_admin/', custom_site.urls, name="super_admin"), ]
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 blog import views from django.conf import settings from django.conf.urls.static import static from blog.views import PostListView, GalListView, PostDetailView urlpatterns = [ path('admin/', admin.site.urls), path('', views.home, name='home'), path('bio/', views.bio, name='bio'), path('pub/', PostListView.as_view(), name='pub'), path('pub/post_id=<int:pk>/', PostDetailView.as_view(), name='pid'), path('galeria/', GalListView.as_view(), name='gal'), path('contacto/', views.cont, name='cont') ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
#coding: utf-8 from django.conf.urls import patterns, url from blog.views import PostsListView, PostDetailView urlpatterns = patterns('', url(r'^$', PostsListView.as_view(), name='list'), url(r'^(?P<pk>\d+)/$', PostDetailView.as_view()), )
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 django.conf.urls.static import static import settings import xadmin xadmin.autodiscover() from xadmin.plugins import xversion xversion.register_models() from blog.views import (IndexView, PostDetailView, CategoryListView, TagsListView, rate_handler) urlpatterns = [ url(r'^xadmin/', include(xadmin.site.urls)), url(r'^$', IndexView.as_view(), name='homepage'), url(r'^post/(?P<slug>[\w|\-|\d|\W]+?)/$', PostDetailView.as_view()), url(r'^category/(?P<alias>\w+)/', CategoryListView.as_view()), url(r'^tag/(?P<tag>[\w|\.|\-]+)/$', TagsListView.as_view()), url(r'^rate_url/$', rate_handler), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.urls import path from . import views from blog.views import (PostListView, PostDetailView, PostCreateView, PostUpdateView, PostDeleteView, UserPostListView, AddCommentView, ) urlpatterns = [ path('', PostListView.as_view(), name='blog-home'), path('user/<str:username>', UserPostListView.as_view(), name='user-posts'), path('post/<int:pk>/', PostDetailView.as_view(template_name='blog/post_detail.html'), name='post-detail'), path('post/<int:pk>/comment/', AddCommentView.as_view(template_name='blog/add_comment.html'), name='post_comment'), path('post/<int:pk>/update/', PostUpdateView.as_view(), name='post-update'), path('post/<int:pk>/delete/', PostDeleteView.as_view(template_name='blog/post_confirm_delete.html'), name='post-delete'), path('post/new/', PostCreateView.as_view(template_name='blog/post_form.html'), name='post-create'), path('about/', views.about, name='blog-about'), ]
router = DefaultRouter() router.register(r'post', PostViewSet, base_name='api-post') router.register(r'category', CategoryViewSet, base_name='api=category') urlpatterns = [ # path('', post_list, name='index'), # path('category/<category_id>', post_list, name='category-list'), # path('tag/<tag_id>', post_list, name='tag-list'), # path('post/<post_id>.html', post_detail, name='post-detail'), path('', IndexView.as_view(), name='index'), path('category/<category_id>', CategoryView.as_view(), name='category-list'), path('tag/<tag_id>', TagView.as_view(), name='tag-list'), path('post/<post_id>.html', PostDetailView.as_view(), name='post-detail'), path('search/', SearchView.as_view(), name='search'), path('author/<owner_id>', AuthorView.as_view(), name='author'), path('links/', LinkView.as_view(), name='links'), path('comment/', CommentView.as_view(), name='comment'), path('rss/', LatestPostFeed(), name='rss'), path('sitemap.xml', sitemap_views.sitemap, {'sitemaps': { 'posts': PostSitemap }}), path('category-autocomplete/', CategoryAutocomplete.as_view(), name='category-autocomplete'), path('tag-autocomplete/', TagAutocomplete.as_view(), name='tag-autocomplete'),
from django.urls import path from django.views.decorators.http import require_POST from blog.views import IndexView, PostDetailView, PostCreateView, PostEditView, PostDeleteView, post_like, \ ProfilePageView urlpatterns = [ path('', IndexView.as_view(), name='index'), path('post/<int:pk>', PostDetailView.as_view(), name='full post'), path('post/create/', PostCreateView.as_view(), name='create post'), path('post/edit/<int:pk>', PostEditView.as_view(), name='edit post'), path('post/delete/<int:pk>', PostDeleteView.as_view(), name='delete post'), path('post/like/<int:pk>', post_like, name='like post'), path('profile/<int:pk>', ProfilePageView.as_view(), name='profile page'), ]
from django.conf.urls import url from blog.views import PostList, PostDetailView from . import views urlpatterns = [ # url(r'/add', views.add, name='add'), # url(r'/edit', views.edit, name='edit'), # url(r'/delete', views.delete, name='delete'), url(r'post/(?P<pk>\d+)/', PostDetailView.as_view(), name='post_id'), url(r'', PostList.as_view(), name='all'), ]