Beispiel #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)
Beispiel #2
0
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, include
from blog.views import AddSubscriptionView, CreatePostView, GetMyList, GetUserList,\
    MarkPost, DeleteSubscriptionView, GetAllMyList, UserView,\
    SubscriptionView, NoSubscriptionView, AllPosts, PostView, UserListView,\
    PostTemplateView, LogoutView, FeedView, IndexView, PostListView,\
    PostListAllView
from django.contrib.auth import views as auth_views

urlpatterns = [
    path('login/', auth_views.LoginView.as_view(), name='login'),
    path('api/logout/', LogoutView.as_view()),
    path('list/', PostListView.as_view(), name='list'),
    path('list_all/', PostListAllView.as_view(), name='list_all'),
    path('list/<int:user_id>/', UserListView.as_view(), name='user_list'),
    path('feed/', FeedView.as_view(), name='feed'),
    path('post/<int:post_id>/', PostTemplateView.as_view(), name='post_view'),
    path('api/post/<int:post_id>/', PostView.as_view()),
    path('admin/', admin.site.urls),
    path('api/subscribe/<int:author_id>/', AddSubscriptionView.as_view()),
    path('api/unsubscribe/<int:author_id>/', DeleteSubscriptionView.as_view()),
    path('api/create-post/', CreatePostView.as_view()),
    path('api/list/', GetMyList.as_view()),
    path('api/list-all/', GetAllMyList.as_view()),
    path('api/feed/', AllPosts.as_view()),
    path('api/list/<int:user_id>/', GetUserList.as_view()),
    path('api/mark-read/<int:post_id>/', MarkPost.as_view()),
Beispiel #3
0
from django.conf import settings
from django.contrib import admin
import blog.views as views
from blog.views import OrderListView, OrderDetailsView, OrderCreate, MainPage, ItemList, ItemAuthorList, ItemTagsList, ItemPublisherList, RegisterFormView, LoginFormView, LogoutView

urlpatterns = [
    url(r'^admin/', admin.site.urls, name='admin'),
    url(r'^$', MainPage.as_view(), name='main'),
    url(r'^orders/$', OrderListView.as_view(), name='orders'),
    url(r'^orders/create/item=(?P<item_id>[0-9]+)/$',
        OrderCreate.as_view(),
        name='create_order'),
    url(r'^orders/(?P<pk>[0-9]+)/$',
        OrderDetailsView.as_view(),
        name='order_details'),
    url(r'^itemlist/$', ItemList.as_view(), name='items'),
    url(r'^itemlist/authors/(?P<author_id>[0-9]+)/$',
        ItemAuthorList.as_view(),
        name='author_items'),
    url(r'^itemlist/publisher/(?P<publisher_id>[0-9]+)/$',
        ItemPublisherList.as_view(),
        name='publisher_items'),
    url(r'^itemlist/tags/(?P<tag_id>[0-9]+)/$',
        ItemTagsList.as_view(),
        name='tag_items'),
    url(r'^item/(?P<item_id>[0-9]+)/$', views.item_view, name='item'),
    url(r'^register/$', RegisterFormView.as_view(), name='register'),
    url(r'^login/$', LoginFormView.as_view(), name='login'),
    url(r'^logout/$', LogoutView.as_view(), name='logout'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Beispiel #4
0
from django.conf.urls import url

from blog.views import (
    BlogListView, BlogView, FeedView, SubscribeView, ViewedView, PostView, PostAddView,
    LogoutView, LoginView
)


urlpatterns = [
    url(r'^$', BlogListView.as_view(), name='blog_list'),
    url(r'^view/blog/(?P<id>\d+)/$', BlogView.as_view(), name='blog_view'),
    url(r'^view/post/(?P<id>\d+)/$', PostView.as_view(), name='post_view'),
    url(r'^add/$', PostAddView.as_view(), name='post_add'),
    url(r'^subscribe/(?P<id>\d+)/$', SubscribeView.as_view(), name='subscribe_view'),
    url(r'^viewed/(?P<id>\d+)/$', ViewedView.as_view(), name='viewed_view'),
    url(r'^feed/$', FeedView.as_view(), name='blog_feed'),
    url(r'^logout/$', LogoutView.as_view(), name='blog_logout'),
    url(r'^login/$', LoginView.as_view(), name='blog_login'),
]
Beispiel #5
0
from .views import ping

router = routers.SimpleRouter()
router.register(r"blog", BlogPostViewSet)

schema_view = get_schema_view(
    openapi.Info(title="Simple blog API", default_version="v1"),
    public=True,
    permission_classes=(permissions.AllowAny, ),
)

urlpatterns = [
    path("admin/", admin.site.urls),
    path("ping/", ping, name="ping"),
    path(
        "api/docs/",
        schema_view.with_ui("swagger", cache_timeout=0),
        name="schema-swagger-ui",
    ),
    path("api/register/", RegisterView.as_view(), name="register"),
    path("api/login/", LoginView.as_view(), name="login"),
    path("api/logout/", LogoutView.as_view(), name="logout"),
    path("api/user/", UserView.as_view(), name="current-user"),
    path("api/tags/", TagsView.as_view(), name="tags"),
    path("api/", include(router.urls)),
    path("api/blog/<slug:slug>/comments/",
         CommentsView.as_view(),
         name="comments"),
    path("api/image/", ImageView.as_view(), name="image"),
]
Beispiel #6
0
    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'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from django.views.static import serve  # 模板文件图片解析模块
from settings import MEDIA_ROOT  # 模板文件图片解析路径

from blog.views import BloListView, BloDetailView, RegView, LoginView, LogoutView, IndexView, AddCommentView  #  导入Views函数/类

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^media/(?P<path>.*)$', serve,
        {"document_root": MEDIA_ROOT}),  # 管理媒体文件路径和处理模块
    url(r'^blolist/$', BloListView.as_view(), name="blolist"),  # 博文映射
    url(r'^blodetail/(?P<blog_id>\d+)/$',
        BloDetailView.as_view(),
        name="blodetail"),  # 面经详情映射
    url(r'^ueditor/', include('DjangoUeditor.urls')),  #   增加编辑器映射
    url(r'^register/$', RegView.as_view(), name="register"),  # 用户注册映射
    url(r'^login/$', LoginView.as_view(), name="login"),  # 用户登录页映射
    url(r'^logout/$', LogoutView.as_view(), name="logout"),  # 用户注销映射
    url(r'^$', BloListView.as_view(), name="blolist"),  # 首页映射
    url(r'^addcomment/(?P<blog_id>\d+)/$',
        AddCommentView.as_view(),
        name="addcomment"),  # 用户评论映射
    #    url(r'^$', IndexView.as_view(), name="index"),  # 首页映射
]