Пример #1
0
    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.urls import url
from blog.views import (MainPageView, SignUpView, LoginView, LogoutView,
                        ProfileView, NewPostView, MyDeleteView, PostView,
                        UpdatePostView)
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
    path('admin/', admin.site.urls, name='admin'),
    re_path('signup', SignUpView.as_view(), name='signup'),
    re_path('login', LoginView.as_view(), name='login'),
    re_path('logout', LogoutView.as_view(), name='logout'),
    re_path('profile/', ProfileView.as_view(), name='profile'),
    re_path('newpost', NewPostView.as_view(), name='newpost'),
    re_path('posts/(?P<pid>\d+)', PostView.as_view(), name='post'),
    re_path('update_post/(?P<pk>\d+)', UpdatePostView.as_view(),
            name='update'),
    re_path(
        'delete_post/(?P<pk>\d+)', MyDeleteView.as_view(), name='delete_post'),
    url(r'^$', MainPageView.as_view(), name='index'),
    re_path('index', MainPageView.as_view()),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Пример #2
0
from django.urls import path
from blog.views import HomePageView, CreatePostView, UpdatePostView, ListPageView, DeletePostView

# enables namespacing
app_name = 'blog'

urlpatterns = [
    path('', HomePageView.as_view(), name='home-page'),
    path('posts/', ListPageView.as_view(), name='list-page'),
    path('posts/new/', CreatePostView.as_view(), name='create-page'),
    path('posts/update/<pk>/', UpdatePostView.as_view(), name='update-page'),
    path('posts/delete/<pk>/', DeletePostView.as_view(), name='delete-page')
]
Пример #3
0
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"),
]
Пример #4
0
# from django.contrib.auth import views as auth_views
from . import views
from blog.views import UpdatePostView, PhotosUpload

app_name = 'users'

urlpatterns = [
    # path('login/',UserLoginView.as_view(),name = 'login'),
    path('register/', UserRegisterView.as_view(), name='register'),
    path('settings/', ProfileSettingsView.as_view(), name='settings-profile'),
    # path('password/',auth_views.PasswordChangeView.as_view(template_name='registration/change_password.html'),name = 'password-change'),
    path('password/', PasswordView.as_view(), name='password-change'),
    path('password/success',
         views.password_change_success,
         name='password_success'),
    path('profile/<int:pk>', ProfileUsers.as_view(), name='profile-page'),
    path('profile/<int:pk>/update',
         EditProfileUsers.as_view(),
         name='edit-profile-page'),
    path('profile/create', CreateProfile.as_view(),
         name='create-profile-page'),
    path('profile/newpost/<int:pk>',
         UpdatePostView.as_view(),
         name='make-post'),
    # path('profile/posts', UpdatePostList.as_view(), name='users-update'),
    path('profile/update/<int:id>',
         UpdateStatusView.as_view(),
         name='status-update'),
    path('profile/pic/<int:id>', PhotosUpload.as_view(), name='pic-upload')
]
Пример #5
0
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,include
from userwork.views import profile
from blog.views import blog , blogpost ,AddPostView,UpdatePostView , DeletePostView
from django.conf.urls.static import static
from django.conf import settings



urlpatterns = [
    path('admin/', admin.site.urls),
    path('',include('userwork.urls')),
    path('accounts',include('django.contrib.auth.urls')),
    path('profile/',profile,name='profile'),
    path('blog/',include('blog.urls')),
    path('blogpost/<int:id>', blogpost , name='blogpost'),
    path('addpost/',AddPostView.as_view(), name='addpost'),
    path('blogpost/updatepost/<int:pk>' , UpdatePostView.as_view(), name = 'updatepost'),
    path('blogpost/<int:pk>/deletepost/' , DeletePostView.as_view(), name = 'deletepost'),
]+ static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
Пример #6
0
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.views import PostListView
from blog.views import PostDetailView
from blog.views import PostCreateView
from blog.views import UpdatePostView
from blog.views import DeletePostView
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', PostListView.as_view(), name='post-list'),
    path('create/', PostCreateView.as_view(), name='post-create'),
    path("<pk>/", PostDetailView.as_view(), name='post-detail'),
    path("<pk>/update/", UpdatePostView.as_view(), name='post-update'),
    path("<pk>/delete/", DeletePostView.as_view(), name='post-delete'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(
    settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Пример #7
0
from django.urls import path
from blog import views
from blog.views import AboutView, PostListView, PostDetailView, CreatePostView, PostDeleteView, UpdatePostView, \
    DraftPostView

urlpatterns = [
    path('about/', AboutView.as_view(), name='about'),
    path('', PostListView.as_view(), name='post_list'),
    path('post/<int:pk>/', PostDetailView.as_view(), name='post_detail'),
    path('post/new/', CreatePostView.as_view(), name='post_new'),
    path('post/<int:pk>/edit/', UpdatePostView.as_view(), name='post_edit'),
    path('post/<int:pk>/remove/', PostDeleteView.as_view(), name='post_remove'),
    path('draft/', DraftPostView.as_view(), name='post_draft_list'),
    path('post/<int:pk>/comment',views.add_comment_to_post,name='add_comment_to_post'),
    path('comment/<int:pk>/approve',views.approve_comment,name='approve_comment'),
    path('comment/<int:pk>/delete', views.remove_comment, name='remove_comment'),
    path('post/<int:pk>/publish',views.publish_post,name='publish_post'),
]
Пример #8
0
from django.urls import path
from blog.views import PostListView,PostDetailView,home, CreatePostView, delete_post,showProfileView, UpdatePostView,AddCategorieView,sameCategorieList,categorieListView,like_view,AddCommentView

app_name = 'blogs'

urlpatterns = [
    path("",home,name='home'),
    path('blog/',PostListView.as_view(),name='post_list'),
    path('blog/<int:pk>/',PostDetailView.as_view(),name='post_detail'),
    path('blog/create/', CreatePostView.as_view(), name='create_post'),
    path('blog/<int:id>/delete/', delete_post, name='delete_post'),
    path('blog/update/<int:pk>', UpdatePostView.as_view(), name='update_post'),
    path('blog/add_categorie/', AddCategorieView.as_view(), name='add_categorie'),
    path('blog/categorie/<str:cats>/', sameCategorieList, name='same_categorie_list'),
    path('blog/categorie_list/', categorieListView, name='categorie_list'),
    path('blog/like/<int:pk>', like_view, name='like_view'),
    path('blog/<int:pk>/add_comment/',AddCommentView.as_view(), name ='add_comment_section'),
    path('blog/<int:pk>/author_profile', showProfileView.as_view(), name='showProfileView')
    


]
Пример #9
0
from django.contrib import admin
from blog.views import AddPostView, UpdatePostView, DeletePostView
from django.conf.urls.static import static
from django.conf import settings

admin.autodiscover()

import hello.views

# To add a new path, first import the app:
# import blog
#
# Then add the new path:
# path('blog/', blog.urls, name="blog")
#
# Learn more here: https://docs.djangoproject.com/en/2.1/topics/http/urls/

urlpatterns = [
    path("", hello.views.index, name="index"),
    path("db/", hello.views.db, name="db"),
    path("admin/", admin.site.urls),
    path("blog/", include("blog.urls")),
    path('add_post/', AddPostView.as_view(), name='add_post'),
    path('post/edit/<int:pk>', UpdatePostView.as_view(), name='update_post'),
    path('post/<int:pk>/remove', DeletePostView.as_view(), name='delete_post'),
    path('members/',
         include('django.contrib.auth.urls')),  # This one for django system
    path('ckeditor/', include('ckeditor_uploader.urls')),
    # path('members/', include('members.urls')),  # This one will be defined in app's urls
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Пример #10
0
urlpatterns = [
    path('', HomePageView.as_view(), name='home'),
    path('add/', csrf_exempt(AddPostView.as_view()), name='add_post'),
    path('blog/', BlogPageView.as_view(), name='blog'),
    path('admin/', admin.site.urls),
    path('login/', csrf_exempt(LoginView.as_view()), name='login'),
    path('logout/', LogoutView.as_view(), name='logout'),
    path('register/', csrf_exempt(RegisterView.as_view()), name='register'),
    path('tag/<str:tag>/', TagListView.as_view(), name='tag'),
    path('post/<int:pk>/', PostPageView.as_view(), name='post'),
    path('category/<str:category>/',
         CategoryListView.as_view(),
         name='category'),
    path('post/<int:pk>/edit/',
         csrf_exempt(UpdatePostView.as_view()),
         name='post_edit'),
    path('post/<int:pk>/addcomment/',
         csrf_exempt(AddCommentView.as_view()),
         name='add_comment'),
    path('reply/comment/<int:id>/',
         csrf_exempt(ReplyCommentView.as_view()),
         name='reply_comment'),
]

schema_view = get_schema_view(title='Blog API')

urlpatterns += format_suffix_patterns([
    path('api/v1/', schema_view),
    path('api/v1/user/',
         UserViewSet.as_view({'get': 'list'}),