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.conf.urls.static import static from django.contrib import admin from django.urls import path, re_path, include from blog import settings from post.views import PostListView, PostDetailView, add_post urlpatterns = [ path('admin/', admin.site.urls), path('', PostListView.as_view(), name="post-list"), path('detail/<int:pk>/', PostDetailView.as_view(), name="post-detail"), path('add/', add_post, name="post-add"), re_path(r'^ajaximage/', include('ajaximage.urls')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) \ + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.conf.urls.defaults import patterns, include, url from post.views import PostListView, PostDetailView from post.models import Post urlpatterns = patterns('', url(r'^$', PostListView.as_view(), name='home'), url(r'^blog/$', PostListView.as_view(), name='blog'), url(r'^blog/entry/(?P<pk>[\d]+)$', PostDetailView.as_view(), name='post-detail'), )
path("", user_view.index, name="homepage"), path("admin/", admin.site.urls, name="admin"), # Game Related Links path("viewGames/", AllGameView.as_view(), name="games"), path("viewGames/<int:game_id>/", GameTitleView, name="game-title"), path("newGame/", AddGameView.as_view(), name="add-game"), path("viewGames/platform/<str:platform>/", PlatformView, name="platform"), path("viewGames/search/<str:title>/", Search, name="search"), # Auth Links path("login/", auth_view.login_view, name="login"), path("signup/", auth_view.signup_view, name="signup"), path("logout/", auth_view.logout_view, name="logout"), # Post Links path("post/add/", PostCreate.as_view(), name="post-create"), path("posts/<int:pk>/", PostDetailView.as_view(), name="post_detail"), path("posts/", PostListView.as_view(), name="post-list"), path("post/<int:pk>/comment/", add_comment_to_post, name="add_comment_to_post"), # Follow Links path("follow/<int:user_id>", follower_view, name="follow"), path("unfollow/<int:user_id>", unfollow_view, name="unfollow"), # User/Profile Links path("user/<int:CustomUser_id>/", user_profile_view, name="user-profile"), # path("viewProfile/<str:username>/", user_profile_view, name="profile"), path("viewUsers/", user_list_view, name="users"), # Favorites path("favorite_game/<int:game_id>", favorite_game_view, name="favorite_game"), path("unfavorite_game/<int:game_id>", unfavorite_game_view, name="unfavorite_game"), # Statics ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # TODO Add other errors
from django.conf.urls import url from post.views import (PostCreateView, PostDetailView, PostDeleteView, PostListView, PostUpdateView, AuthorPostView) app_name = 'post' urlpatterns = [ url(r'^$', PostListView.as_view(), name='List'), url(r'^create', PostCreateView.as_view(), name='Create'), url(r'^detail/(?P<pk>[\d-]+)/$', PostDetailView.as_view(), name='Details'), url(r'^update/(?P<pk>[\d-]+)/$', PostUpdateView.as_view(), name='Update'), url(r'^delete/(?P<pk>[\d-]+)/$', PostDeleteView.as_view(), name='Delete'), url(r'^author/(?P<username>[-\w]+)/$', AuthorPostView.as_view(), name='Author-Post') ]
from django.urls import path from post.views import PostListView, PostCreateView, PostDeleteView, PostUpdateView app_name = 'post' urlpatterns = [ path('postagens', PostListView.as_view(), name='listar_postagens'), path('criarpostagem', PostCreateView.as_view(), name='criar_postagem'), path('postagens/<int:pk>/apagar', PostDeleteView.as_view(), name='deletar_postagem'), path('postagens/<int:pk>/editar', PostUpdateView.as_view(), name='editar_postagem'), ]
from django.urls import path from post.views import PostListView, PostCreateView, PostDeleteView, PostUpdateView app_name = 'post' urlpatterns = [ path('posts', PostListView.as_view(), name="listaposts"), path('criarposts', PostCreateView.as_view(), name="criarpost"), path('posts/<int:pk>/apagar', PostDeleteView.as_view(), name="deletarpost"), path('posts/<int:pk>/update', PostUpdateView.as_view(), name="updatepost") ]
The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.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')) """ from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include from post.views import PostListView, PostDetailView, PostCreateView, PostUpdateView urlpatterns = [ path('admin/', admin.site.urls), path('accounts/', include('django.contrib.auth.urls')), path('', PostListView.as_view(), name='home'), path('<int:pk>/', PostDetailView.as_view(), name='post_detail'), path('new-post/', PostCreateView.as_view(), name='post_creation'), path('post/<int:pk>/', PostUpdateView.as_view(), name='post_update'), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
from django.conf.urls import patterns, url from post.views import PostListView, PostDetailView, PostCreateView urlpatterns = patterns( 'post.views', url(r'^$', PostListView.as_view(), name='post-list'), url(r'^(?P<slug>[-_\w]+)/$', PostDetailView.as_view(), name='post-detail'), url(r'^add$', PostCreateView.as_view(), name='post-add'), )
from django.conf.urls import url, include from post.views import PostListView, PostDetailView urlpatterns = [ url(r'^posts/$', PostListView.as_view(), name='post-list'), url(r'^posts/(?P<pk>[0-9]+)/$', PostDetailView.as_view(), name='post-detail'), url(r'^posts/(?P<pk>[0-9]+)/comments/', include('comment.urls')), ]
from django.conf.urls.static import static from django.urls import path, include from post.views import PostListView, post_search, post_detail, tagged, CategoryView, CategoryListView #CategoryListView from django.contrib.sitemaps.views import sitemap from .sitemaps import PostSitemap from django.conf.urls import url from .feeds import LatestPostsFeed sitemaps = { "posts": PostSitemap, } urlpatterns = [ path('grappelli/', include('grappelli.urls')), # grappelli URLS path('admin/', admin.site.urls), path('tinymce/', include('tinymce.urls')), path('', PostListView.as_view(), name='blog'), path('search/', post_search, name='post_search'), path('<slug:post>/', post_detail, name='post_detail'), path("sitemap.xml/", sitemap, {"sitemaps": sitemaps}, name="django.contrib.sitemaps.views.sitemap"), path("feed/rss", LatestPostsFeed(), name="post_feed"), path('hitcount/', include(('hitcount.urls', 'hitcount'), namespace='hitcount')), path('tag/<slug:slug>/', tagged, name="tagged"), path('category/<slug:slug>/', CategoryView, name='category'), path('category-list/', CategoryListView.as_view(), name='category-list'), ] if settings.DEBUG: urlpatterns += static(settings.STATIC_URL,
path('posts/author/<username>/', PostListByAuthor.as_view(), name='post-author'), path('posts/<int:year>/<int:month>/<int:day>/<slug:slug>/', PostDetail.as_view(), name='post-detail'), path('posts/<int:year>/<int:month>/<int:day>/', PostListByDay.as_view(), name='post-detail'), path('posts/<int:year>/<int:month>/', PostListByMonth.as_view(), name='post-detail'), path('posts/<int:year>/', PostListByYear.as_view(), name='post-detail'), path('dj-admin/', login_required(Dashboard.as_view()), name='dj-admin-view'), path('dj-admin/posts/', login_required(PostListView.as_view()), name='dj-admin-posts-view'), path('dj-admin/posts/add/', login_required(PostAddView.as_view()), name='dj-admin-posts-add-view'), path('dj-admin/posts/<int:pk>/', login_required(PostEditView.as_view()), name='dj-admin-posts-update-view'), path('dj-admin/settings/', login_required(SiteSettingEdit.as_view()), name='dj-admin-sitesetting-view'), path('accounts/login/', LoginView.as_view(), name='login'), ]
from django.conf import settings from django.conf.urls import url from django.conf.urls import include from django.conf.urls.static import static from django.contrib import admin from django.contrib.auth.views import login from django.contrib.auth.views import logout from post.views import PostListView urlpatterns = [ url(r'^$', PostListView.as_view(), name="home"), url(r'^login/$', login, {'template_name': 'login.html'}, name='login',), url(r'^logout/$', logout, {'next_page': settings.LOGIN_URL}, name='logout'), url(r'^post/', include('post.urls'), name="post"), url(r'^admin/', admin.site.urls), ] if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns.append( url(r'',include('social.apps.django_app.urls', namespace='social')) )
from django.urls import path from post.views import PostListView urlpatterns = [path('', PostListView.as_view())]
from django.urls import path from post.views import PostDetailView, PostListView app_name = 'post' urlpatterns = [ path('post/<int:pk>/', PostDetailView.as_view(), name='post-detail-view'), path('post-feed/', PostListView.as_view(), name='post-list-view') ]
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.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include from post.views import IndexPageView, PostDetailsView, PostListView, PostDeleteView, CreatePostView, \ PostEditView, SearchResultsView urlpatterns = [ path('admin/', admin.site.urls), path('account/', include('account.urls')), path('', IndexPageView.as_view(), name='index-page'), path('post/create/', CreatePostView.as_view(), name='create-post'), path('post/search/', SearchResultsView.as_view(), name='search-results'), path('post/<slug:post_slug>/', PostListView.as_view(), name='post-list'), path('post/details/<int:pk>/', PostDetailsView.as_view(), name='post-details'), path('post/delete/<int:pk>/', PostDeleteView.as_view(), name='delete-post'), path('post/edit/<int:pk>/', PostEditView.as_view(), name='edit-post'), path('post/', PostListView.as_view(), name='post-list') ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.urls import path from post.views import PostListView, PostDetailView app_name = 'post' urlpatterns = [ path('', PostListView.as_view(), name='post-list'), path('<int:pk>/', PostDetailView.as_view(), name='post-detail'), ]
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 debug_toolbar from django.conf.urls import url, include from django.conf.urls.i18n import i18n_patterns from django.contrib import admin from django.conf.urls.static import static from application import settings from post.views import PostListView from rating.views import PostRatings urlpatterns = [ url(r'^i18n/', include('django.conf.urls.i18n')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += i18n_patterns( url(r'^admin/', admin.site.urls), url(r'^post/', include('post.urls', namespace="post")), url(r'^user/', include('core.urls', namespace='user')), url(r'^page(?P<page>\d+)/$', PostListView.as_view()), url(r'^$', PostListView.as_view(), name='list'), url(r'^posts_rating/$', PostRatings.as_view(), name='ratings'), ) if settings.DEBUG: urlpatterns += [url(r'^__debug__/', include(debug_toolbar.urls))]
from django.conf import settings from django.conf.urls.static import static from django.urls import path from post.views import PostDetailView, PostListView urlpatterns = [ path(r'', PostListView.as_view()), path(r'detail/<pk>', PostDetailView.as_view()), ] # 開発環境でのメディアファイルの配信設定 urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.contrib import admin from django.urls import path from django.contrib.auth import views as auth_views from post.views import home, PostListView, PostDetailView, PostCreateView, PostUpdateView, PostDeleteView, WatchCreateView from register.views import register, profile from django.conf.urls.static import static from django.conf import settings urlpatterns = [ path('admin/', admin.site.urls), path('post/', PostListView.as_view(), name='posts'), path('', PostListView.as_view(), name='home'), path('post/<int:pk>/', PostDetailView.as_view(), name='post-detail'), path('post/new/', PostCreateView.as_view(), name='post-create'), path('post/<int:pk>/update/', PostUpdateView.as_view(), name='post-update'), path('post/<int:pk>/delete/', PostDeleteView.as_view(), name='post-delete'), path('register/', register, name='register'), path('login/', auth_views.LoginView.as_view(template_name='register/login.html'), name='login'), path('logout/', auth_views.LogoutView.as_view(template_name='register/logout.html'), name='logout'), path('profile/', profile, name='profile'), path('post/private', PostListView.as_view(template_name='post/private.html'), name='post-private'), path('post/invited', PostListView.as_view(template_name='post/invited.html'),
from django.urls import include, path, re_path from post.views import ( PostCreateView, PostDetailView, PostDeleteView, PostListView, PostUpdateView, ) urlpatterns = [ re_path(r'^$', PostListView.as_view(), name="List"), re_path(r'^create', PostCreateView.as_view(), name="Create"), re_path(r'^detail/(?P<pk>[\d-]+)/$', PostDetailView.as_view(), name="Details"), re_path(r'update/(?P<pk>[\d-]_)/$', PostUpdateView.as_view(), name="Update"), re_path(r'^delete/(?P<pk>[\d]+)/$', PostDeleteView.as_view(), name="Delete") ]
from django.conf.urls import url from post.views import (NewPostView, PostListView, CommentView, PostDetailView, ProfilePage, UserProfilePage, ChangeAvatarView, LikeView) from django.conf import settings from django.conf.urls.static import static urlpatterns = [ url(r'^(?P<user_name>[a-zA-z0-9.]+)/profile/$', UserProfilePage.as_view(), name='user_profile'), url(r'^profile/avatar/$', ChangeAvatarView.as_view(), name='change_avatar'), url(r'^post/new/$', NewPostView.as_view(), name='new_post'), url(r'^profile/me/$', ProfilePage.as_view(), name='profile'), url(r'^post/like/(?P<post_id>\d+)/$', LikeView.as_view(), name='like'), url(r'^post/comment/(?P<post_id>\d+)/$', CommentView.as_view(), name='comment'), url(r'^post/(?P<post_id>\d+)/$', PostDetailView.as_view(), name='post'), url(r'^$', PostListView.as_view(), name='posts'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)