Exemplo n.º 1
0
    https://docs.djangoproject.com/en/3.0/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'))
"""
#PostView , PostCreateView ,UserCreateAPIView

from django.contrib import admin
from django.urls import path, include
from app.views import PostView, PostCreateView, PostListCreateView, registration_view
from rest_framework.authtoken.views import obtain_auth_token

urlpatterns = [
    path('api-auth/', include('rest_framework.urls')),
    path('rest-auth/', include('rest_auth.urls')),
    path('admin/', admin.site.urls),
    path('', PostView.as_view(), name='test'),
    path('create/', PostCreateView.as_view(), name='create'),
    # path('login/', UserLoginAPIView.as_view(), name='login'),
    path('register/', registration_view, name='register'),
    path('list-create/', PostListCreateView.as_view(), name='list-create'),
    path('api/token/', obtain_auth_token, name='obtain_auth_token')
]
Exemplo n.º 2
0
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from app.views import (IndexView, UserCreateView, ProfileView, PostCreateView,
                       PostDetailCommentCreateView, PostUpdateView,
                       PostDeleteView, CommentUpdateView)

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url('^', include('django.contrib.auth.urls')),
    url(r'^create_user/$', UserCreateView.as_view(), name="user_create_view"),
    url(r'^$', IndexView.as_view(), name="index_view"),
    url(r'^accounts/profile/$', ProfileView.as_view(), name="profile_view"),
    url(r'^post/create/$', PostCreateView.as_view(), name="post_create_view"),
    url(r'^post/(?P<pk>\d+)/$',
        PostDetailCommentCreateView.as_view(),
        name="post_detail_comment_create_view"),
    url(r'^post/(?P<pk>\d+)/update/$',
        PostUpdateView.as_view(),
        name="post_update_view"),
    url(r'^post/(?P<pk>\d+)/delete/$',
        PostDeleteView.as_view(),
        name="post_delete_view"),
    url(r'^comment/(?P<pk>\d+)/update/$',
        CommentUpdateView.as_view(),
        name="comment_update_view")
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Exemplo n.º 3
0
    cancel_friend_request,
    SendFriendRequestView,
    UnfriendView,
    RegisterView,
    LoginView,
    LogoutView,
)

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('logout/', LogoutView.as_view(), name='logout'),
    path('post/<int:pk>', post_detail, 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'),
Exemplo n.º 4
0
urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('django.contrib.auth.urls')),
    url(r'^$', SubredditListView.as_view(), name="subreddit_list_view"),
    url(r'^create/subreddit/$',
        SubredditCreateView.as_view(),
        name="subreddit_create_view"),
    url(r'^subreddit/(?P<pk>\d+)/$',
        SubredditDetailView.as_view(),
        name="subreddit_detail_view"),
    url(r'^subreddit/update/(?P<pk>\d+)$',
        SubredditUpdateView.as_view(),
        name="subreddit_update_view"),
    url(r'^post/update/(?P<pk>\d+)$',
        PostUpdateView.as_view(),
        name="post_update_view"),
    url(r'^comment/update/(?P<pk>\d+)$',
        CommentUpdateView.as_view(),
        name="comment_update_view"),
    url(r'^post/(?P<pk>\d+)/$',
        PostDetailView.as_view(),
        name="post_detail_view"),
    url(r'^create/post/(?P<pk>\d+)/$',
        PostCreateView.as_view(),
        name="post_create_view"),
    url(r'^create/comment/(?P<pk>\d+)$',
        CommentCreateView.as_view(),
        name="comment_create_view"),
]
Exemplo n.º 5
0
from django.contrib.auth import views as auth_views
from app.views import MainView, CreateUserView, MyAccountView, CityCreateView, CityListView, CategoryByCityDetailView, SubCategoryView, PostView, PostCreateView, SuccessPostView, \
    PostDetailView, CategoryListCreateAPIView, CategoryRetrieveUpdateDestroyAPIView, SubCategoryListCreateAPIView, \
    SubCategoryRetrieveUpdateDestroyAPIView, PostRetrieveUpdateDestroyAPIView, \
    PostBySubListCreateAPIView, PostByCatListCreateAPIView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', MainView.as_view(), name="main_view"),
    url(r'^create_user/$', CreateUserView.as_view(), name='create_user_view'),
    url(r'^login/$', auth_views.login, name='login_view'),
    url(r'^logout/$', auth_views.logout_then_login, name='logout_view'),
    url(r'^my_account/(?P<pk>\d+)/$', MyAccountView.as_view(), name='my_account_view'),
    url(r'^media/(?P<path>.*)', 'django.views.static.serve', {"document_root": settings.MEDIA_ROOT}),
    url(r'^successfully_posted/', SuccessPostView.as_view(), name='success'),
    url(r'^create_city/', CityCreateView.as_view(), name='city_create_view'),
    url(r'^city_list/$', CityListView.as_view(), name="city_list_view"),
    url(r'^categories_by_city/(?P<pk>\d+)/$', CategoryByCityDetailView.as_view(), name="category_by_city_detail_view"),
    url(r'^subcategory/(?P<pk>\d+)/$', SubCategoryView.as_view(), name='subcategory_view'),
    url(r'^post_by_sub/(?P<pk>\d+)/$', PostView.as_view(), name="post_view"),
    url(r'^post_create/(?P<sub_id>\d+)/$', PostCreateView.as_view(), name='post_create_view'),
    url(r'^post_detail/(?P<pk>\d+)/$', PostDetailView.as_view(), name='post_detail_view'),
    url(r'^api/categories/$', CategoryListCreateAPIView.as_view()),
    url(r'^api/categories/(?P<pk>\d+)/$', CategoryRetrieveUpdateDestroyAPIView.as_view()),
    url(r'^api/subcategories/$', SubCategoryListCreateAPIView.as_view()),
    url(r'^api/subcategories/(?P<pk>\d+)/$', SubCategoryRetrieveUpdateDestroyAPIView.as_view()),
    url(r'^api/subcategories/(?P<pk>\d+)/post/$', PostBySubListCreateAPIView.as_view()),
    url(r'^api/categories/(?P<pk>\d+)/post/$', PostByCatListCreateAPIView.as_view()),
    url(r'^api/posts/(?P<pk>\d+)/$', PostRetrieveUpdateDestroyAPIView.as_view()),
]
Exemplo n.º 6
0
    CommentEditView,
    CommentDeleteView,
    PostCreateView,
    PostEditView,
    PostDeleteView,
    PostListView,
    PostDetailView,
)
urlpatterns = [
    url(r'^$', HomePageView.as_view(), name='home'),
    url(r'^admin/', admin.site.urls),
    url(r'^post/(?P<pk>[0-9]+)/comment/create$',
        CommentCreateView.as_view(),
        name='comment_create'),
    url(r'^post/(?P<pk>[0-9]+)/comment/(?P<pk_comment>[0-9]+)/edit$',
        CommentEditView.as_view(),
        name='comment_edit'),
    url(r'^post/(?P<pk>[0-9]+)/comment/(?P<pk_comment>[0-9]+)/delete$',
        CommentDeleteView.as_view(),
        name='comment_delete'),
    url(r'^post/$', PostListView.as_view(), name='post_list'),
    url(r'^post/(?P<pk>[0-9]+)/$',
        PostDetailView.as_view(),
        name='post_detail'),
    url(r'^post/(?P<pk>[0-9]+)$', PostCreateView.as_view(),
        name='post_create'),
    url(r'^post/(?P<pk>[0-9]+)$', PostEditView.as_view(), name='post_update'),
    url(r'^post/(?P<pk>[0-9]+)$', PostDeleteView.as_view(),
        name='post_delete'),
]