コード例 #1
0
from django.contrib import admin
from django.urls import path, include
from app.views import PostList, PostDetail, SignUpView, UserDetail, SearchView

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', PostList.as_view(), name='home'),
    path('post/<slug:slug>/', PostDetail.as_view(), name='post_detail'),
    path('user/<int:pk>/', UserDetail.as_view(), name='user_detail'),
    path('search/', SearchView.as_view(), name='search'),
]

urlpatterns += (
    path('signup/', SignUpView.as_view(), name='signup'),
    path('accounts/', include('django.contrib.auth.urls')),
)

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
コード例 #2
0
from app.views import \
        PostList, PostDetail, \
        CategoryList, CategoryDetail, \
        AuthorList, AuthorDetail
from django.urls import path

app_name = 'app'
urlpatterns = [
    path('', PostList.as_view(), name='post-list'),
    path('<int:pk>', PostDetail.as_view(), name='post-detail'),
    path('categories/', CategoryList.as_view(), name='category-list'),
    path('categories/<int:pk>',
         CategoryDetail.as_view(),
         name='category-detail'),
    path('authors/', AuthorList.as_view(), name='author-list'),
    path('authors/<int:pk>', AuthorDetail.as_view(), name='author-detail'),
]
コード例 #3
0
  CommentEditView,
  CommentDeleteView,
  accept_friend_request,
  AcceptFriendRequestView,
  reject_friend_request,
  cancel_friend_request,
  RegisterView,
  LoginView,
)

urlpatterns = [
  path('', index, name='post_list'),
  path('', PostListView.as_view(), name='post_list'),
  path('register/', RegisterView.as_view(), name='register'),
  path('login/', LoginView.as_view(), name='login'),
  path('post/<int:pk>', PostDetail.as_view(), name='post_detail'),
  path('post/create', PostCreateView.as_view(), name='post_create'),
  path('post/<int:pk>/edit', post_edit, name='post_edit'),
  path('post/<int:pk>/edit', PostEditView.as_view(), name='post_edit'),
  path('post/<int:pk>/delete', post_delete, name='post_delete'),
  path('post/<int:pk>/delete', PostDeleteView.as_view(), name='post_delete'),
  path('post/<int:pk>/comment/create', comment_create, name='comment_create'),
  path('post/<int:pk>/comment/create', CommentCreateView.as_view(), name='comment_create'),
  path('post/<int:pk>/comment/<int:pk_comment>/edit', CommentEditView.as_view(), name='comment_edit'),
  path('post/<int:pk>/comment/<int:pk_comment>/delete', CommentDeleteView.as_view(), name='comment_delete'),
  path('userprofile', UserProfileView.as_view(), name='user_profile'),
  path('userprofile/<int:pk>', UserProfileView.as_view(), name='user_profile'),
  path('userprofile/<int:pk>/edit', UserProfileUpdateView.as_view(), name='user_profile_edit'),
  path('userprofile/<int:pk>/relations', UserProfileRelationsView.as_view(), name='user_profile_relations'),
  path('accept_friend_request/<int:user_pk>', AcceptFriendRequestView.as_view(), name='accept_friend_request'),
  path('reject_friend_request/<int:user_pk>', reject_friend_request, name='reject_friend_request'),