示例#1
0
文件: urls.py 项目: po1nt710/blog
"""blogproject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    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. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from blog.views import ArticleListView, ArticleDetailView

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', ArticleListView.as_view()),  # Главная страница со списком всех записей блога
    url(r'^(?P<article_id>[0-9]+)/$', ArticleDetailView.as_view()),  # Страница записи с комментариями
]
示例#2
0
from django.conf.urls import patterns, url
from blog.views import ArticleListView, TagListView, ArticleDetailView, AuthorListView
from blog.feeds import BlogFeed

urlpatterns = patterns('blog.views',
                       url(r'^$', ArticleListView.as_view(), name='blog_index'),
                       url(r'^tag/(?P<pk>\d+)/$', TagListView.as_view(), name='tag_index'),
                       url(r'^(?P<pk>\d+)/$', ArticleDetailView.as_view(), name='article_detail'),
                       url(r'^author/(?P<name>[^/]+)/$', AuthorListView.as_view(), name='author_list'),
                       url(r'^feed/$', BlogFeed(), name='blog_rss')
                       )
示例#3
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.urls import path

from blog.views import (
    ArticleDetailView,
    ArticleListView,
    ArticleCreateView,
    ArticlePkAndSlugDetailView,
    ArticleUniqueSlugDetailView,
)

urlpatterns = [
    path("", ArticleListView.as_view(), name="article-list"),
    path("blog/create", ArticleCreateView.as_view(), name="article-create"),
    path("blog/<int:pk>/", ArticleDetailView.as_view(), name="article-detail"),
    path(
        "blog/<int:pk>-<str:slug>/",
        ArticlePkAndSlugDetailView.as_view(),
        name="article-pk-slug-detail",
    ),
    path(
        "blog/<str:slug>",
        ArticleUniqueSlugDetailView.as_view(),
        name="articleunique-slug",
    ),
]
示例#4
0
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import include, path
from django.contrib.auth import get_user_model
from rest_framework import routers
from rest_auth.views import LogoutView
from core.views_auth import BluewhaleLoginView, get_user_info, send_verification_mail,\
    verify_verification_token,\
    register
from blog.views import ArticleListCreateView, ArticleDetailView
from rest_framework import routers


api_prefix = 'api/v1'

router = routers.DefaultRouter()

urlpatterns = [
    # path('admin/', admin.site.urls),
    path(f'{api_prefix}/login', BluewhaleLoginView.as_view(), name='rest_login'),   #登陆
    path(f'{api_prefix}/logout', LogoutView.as_view(), name='rest_logout'),
    path(f'{api_prefix}/send-verification', send_verification_mail, name='send verification mail'),
    path(f'{api_prefix}/verify/<token>', verify_verification_token, name='verify verification token'),
    path(f'{api_prefix}/register', register, name='register'),
    path(f'{api_prefix}/me', get_user_info, name='user profile'),   # 获得用户信息

    path(f'{api_prefix}/articles', ArticleListCreateView.as_view(), name='articles'),
    path(f'{api_prefix}/articles/<pk>', ArticleDetailView.as_view(), name='article'),
    path(f'{api_prefix}/', include(router.urls)),
]
示例#5
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, include
from home import views
from blog.views import ArticleDeleteView, ArticleListView, ArticleDetailView, ArticleCreateView, ArticleUpdateView
from accounts.views import UserFormView
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('blog/<int:id>/update/', ArticleUpdateView.as_view()),
    path('blog/create/', ArticleCreateView.as_view()),
    path('blog/<int:id>/', ArticleDetailView.as_view(), name='article-detail'),
    path('blog/', ArticleListView.as_view(), name='article-list'),
    path('admin/', admin.site.urls),
    path('home/', views.main, name="main"),
    path('index/', views.main, name="main"),
    path('logout/', views.logout_user, name="logout"),
    path('search/', views.search, name="search"),
    path('<int:id>/guideprofile/', views.guide_profile, name="guide_profile"),
    path('register/', views.register),
    path('<int:id>/detail/', views.detail),
    path('blog/', include('blog.urls')),
    path('accounts/', include('accounts.urls')),
    path('login/', UserFormView.as_view()),
    path('arts/', include('arts.urls')),
]
if settings.DEBUG:
示例#6
0
from django.urls import path

from blog.views import (ArticleListView, ArticleDetailView,
                        ArticleLikeCreateView, CommentsView, CommentEditView,
                        CommentCreateView, CommentDelete,
                        CommentLikeCreateView, LikesView)

app_name = "blog"

urlpatterns = [
    path('', ArticleListView.as_view(), name='index'),
    path('<int:pk>/', ArticleDetailView.as_view(), name='detail'),
    path('<int:pk>/comments/', CommentsView.as_view(), name='comments_get'),
    path('<int:pk>/likes/', LikesView.as_view(), name='likes_get'),
    path('comments/add/', CommentCreateView.as_view(), name='comment_add'),
    path('comments/<int:pk>/edit/',
         CommentEditView.as_view(),
         name='comment_edit'),
    path('comments/delete/', CommentDelete.as_view(), name='comment_delete'),
    path('likes/articles/add/',
         ArticleLikeCreateView.as_view(),
         name='like_article_add'),
    path('likes/comments/add/',
         CommentLikeCreateView.as_view(),
         name='like_comment_add'),
]
示例#7
0
from django.urls import path

from blog.views import ArticleIndexView, ArticleListView, ArticleDetailView
from blog.views import TutorialListView, TutorialDetailView, TutorialArticleListView, TutorialCommentsView

urlpatterns = [
    # 文章列表页
    path('article/index/', ArticleIndexView.as_view(), name='blog_article_index'),
    path('article/list/', ArticleListView.as_view(), name='blog_article_list'),
    path('article/detail/<int:article_id>', ArticleDetailView.as_view(), name='blog_article_detail'),

    # 教程列表页
    path('tutorial/list/', TutorialListView.as_view(), name='blog_tutorial_list'),
    path('tutorial/detail/<int:tutorial_id>/', TutorialDetailView.as_view(), name='blog_tutorial_detail'),
    path('tutorial/info/<int:tutorial_id>/', TutorialArticleListView.as_view(), name='blog_tutorial_article_list'),
    path('tutorial/comments/<int:tutorial_id>/', TutorialCommentsView.as_view(), name='blog_tutorial_comments'),

    # path('detail/<int:course_id>/', CourseDetailView.as_view(), name='course_detail'),
    # path('info/<int:course_id>/', CourseInfoView.as_view(), name='course_info'),
    # path('comments/<int:course_id>/', CourseCommentsView.as_view(), name='course_comments'),

    # 添加博客评论
    # path('add_comment/', CourseAddCommentView.as_view(), name='add_comment'),

    # 播放视频
    # path('video/<int:video_id>/', VideoPlayView.as_view(), name='video_play'),

]
示例#8
0
api_prefix = 'api/v1'

router = routers.DefaultRouter()

urlpatterns = [
    # path('admin/', admin.site.urls),
    path(f'{api_prefix}/login',
         BluewhaleLoginView.as_view(),
         name='rest_login'),
    path(f'{api_prefix}/logout', LogoutView.as_view(), name='rest_logout'),
    path(f'{api_prefix}/send-verification',
         send_verification_mail,
         name='send verification mail'),
    path(f'{api_prefix}/verify/<token>',
         verify_verification_token,
         name='verify verification token'),
    path(f'{api_prefix}/register', register, name='register'),
    path(f'{api_prefix}/me', get_user_info, name='user profile'),
    path(f'{api_prefix}/articles',
         ArticleListCreateView.as_view(),
         name='articles'),
    path(f'{api_prefix}/articles/<pk>',
         ArticleDetailView.as_view(),
         name='article'),
    path(f'{api_prefix}/', include(router.urls)),

    # add
    path(f'{api_prefix}/user/<str:email>', userOperator, name="userOper")
]
示例#9
0
from django.urls import path
from blog.views import (ArticleCreateView, ArticleDetailView,
                        ArticleUpdateView, ArticleDeleteView, ArticleListView)

app_name = "articles"
urlpatterns = [
    path('', ArticleListView.as_view(), name="Article-list"),
    path('create/', ArticleCreateView.as_view(), name="Article-create"),
    path('<int:id>/', ArticleDetailView.as_view(), name="Article-detail"),
    path('<int:id>/update/',
         ArticleUpdateView.as_view(),
         name="Article-update"),
    path('<int:id>/delete/',
         ArticleDeleteView.as_view(),
         name="Article-delete"),
]
示例#10
0
from django.urls import path
from blog.views import ArticleCreateView, ArticleListView, ArticleDeleteView, ArticleDetailView, ArticleUpdateView

app_name = "blog"

urlpatterns = [
    path('create/', ArticleCreateView.as_view(), name='CreateArticle'),
    path('articles/<pk>/', ArticleDetailView.as_view(), name='ArticleDetail'),
    path('<pk>/delete/', ArticleDeleteView.as_view(), name='ArticleDelete'),
    path('<pk>/update/', ArticleUpdateView.as_view(), name='ArticleUpdate'),
    path('articles/', ArticleListView.as_view(), name='ListArticle'),
]
示例#11
0
from django.conf.urls import url
from django.contrib import admin
from blog.views import EmailView, ArticleCreateView, ArticleDetailView, ArticleListView, ArticleMonthArchiveView, ArticleYearArchiveView
from django.conf.urls import url
from django.views.generic.dates import ArchiveIndexView

from blog.models import Article

app_name = 'blog'

urlpatterns = [
    url(r"^$", EmailView.as_view(), name="index"),
    url(r"^create/$", ArticleCreateView.as_view(), name="create"),
    url(r"^list/$", ArticleListView.as_view(), name="list"),
    url(r"^detail/(?P<pk>\d+)/$", ArticleDetailView.as_view(), name="detail"),
    url(r'^archive/$',
        ArchiveIndexView.as_view(model=Article, date_field="pub_date"),
        name="article_archive"),
    url(r'^(?P<year>[0-9]{4})/$',
        ArticleYearArchiveView.as_view(),
        name="article_year_archive"),

    # Example: /2012/aug/
    url(r'^(?P<year>[0-9]{4})/(?P<month>[-\w]+)/$',
        ArticleMonthArchiveView.as_view(),
        name="archive_month"),
    # Example: /2012/08/
    url(r'^(?P<year>[0-9]{4})/(?P<month>[0-9]+)/$',
        ArticleMonthArchiveView.as_view(month_format='%m'),
        name="archive_month_numeric"),
]
示例#12
0
from django.urls import path
from blog.views import ArticleView, NewArticleView, ArticleDetailView

urlpatterns = [
    path('', ArticleView.as_view(), name='all'),
    path('new/', NewArticleView.as_view(), name='new'),
    path('<int:id>/', ArticleDetailView.as_view(), name='detail_url'),
]
示例#13
0
文件: urls.py 项目: beham1993/MyBlog
from django.conf.urls import patterns, url, include
from blog.views import ArticleListView, ArticleDetailView, PersonPageView, ArchiveListView
from django.conf.urls.static import static
from django.conf import settings

if settings.DEBUG:
	urlpatterns = patterns(
	    '',
	    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
		url(r'^i18n/', include('django.conf.urls.i18n')),
	    url(r'^$', ArticleListView.as_view(), name='index'),
	    url(r'^article/(?P<pk>\d+)/$', ArticleDetailView.as_view()),
	    url(r'^archive/$', ArchiveListView.as_view(), name='archive'),
	    url(r'^about_me/$', PersonPageView.as_view(), name="about_me"),
    	url(r'^logout/$', 'blog.views.logout'),

	)
示例#14
0
from django.conf.urls import patterns, url
from blog.views import ArticleListView, TagListView, ArticleDetailView, AuthorListView
from blog.feeds import BlogFeed

urlpatterns = patterns(
    'blog.views', url(r'^$', ArticleListView.as_view(), name='blog_index'),
    url(r'^tag/(?P<pk>\d+)/$', TagListView.as_view(), name='tag_index'),
    url(r'^(?P<pk>\d+)/$', ArticleDetailView.as_view(), name='article_detail'),
    url(r'^author/(?P<name>[^/]+)/$',
        AuthorListView.as_view(),
        name='author_list'), url(r'^feed/$', BlogFeed(), name='blog_rss'))
示例#15
0
from django.urls import path
from blog.views import (ArticleListView, 
                    ArticleDetailView, 
                    ArticleDeleteView, 
                    ArticleFormView, 
                    ContactFormView, 
                    CategoriesArticleListView, 
                    ArticleUptadeView, 
                    CommentDeleteView)
                    

urlpatterns = [
    
    path('', ArticleListView.as_view(), name="homepage"),
    path('article/<slug:slug>', ArticleDetailView.as_view(), name="article-detail"),
    path('article/delete/<slug:slug>', ArticleDeleteView.as_view(), name="article-delete"),
    path('article/create/', ArticleFormView.as_view(), name="article-create"),
    path('article/edit/<slug:slug>', ArticleUptadeView.as_view(), name="article-edit"),

    path('comment/delete/<int:id>', CommentDeleteView.as_view(), name="comment-delete"),


    path('contact/', ContactFormView.as_view(), name="contact"),
    path('category/<slug:slug>', CategoriesArticleListView.as_view(), name="category"),
]
from django.contrib import admin
from django.urls import path
from blog.views import ArticlesListView, ProjectCreateView, UserCreateView, UsersListView, ArticleDetailView, UserDetailView, favorite, CommentCreateView, AnswerCommentCreateView, ProjectUpdateView, change_comment, add_favorite, ProjectDeleteView
from django.conf.urls.static import static
from django.conf import settings

app_name = 'blog'

urlpatterns = [
    path('', ArticlesListView.as_view(), name='index'),
    path('article/<int:pk>', ArticleDetailView.as_view(), name='article'),
    path('article/create', ProjectCreateView.as_view(), name='create_blog'),
    path('projects/<int:pk>/delete',
         ProjectDeleteView.as_view(),
         name='article_delete'),
    path('create_user', UserCreateView.as_view(), name='create_user'),
    path('users', UsersListView.as_view(), name='users'),
    path('user/<int:pk>', UserDetailView.as_view(), name='user'),
    path('user/<int:user_pk>/favorites', favorite, name='favorite'),
    path('article/<int:article_pk>/save', add_favorite, name='add_favorite'),
    path('article/<int:pk>/create_comment',
         CommentCreateView.as_view(),
         name='create_comment'),
    path('article/<int:pk>/comment/<int:comment_pk>/create_answer',
         AnswerCommentCreateView.as_view(),
         name='create_comment_answer'),
    path('article/<int:pk>/update',
         ProjectUpdateView.as_view(),
         name='change_article'),
    path('article/<int:article_pk>/comment/<int:comment_pk>/update',
         change_comment,
示例#17
0
文件: urls.py 项目: fangmd/djangoblog
from django.conf.urls import url

from blog.views import IndexView, ArticleDetailView, CategoryView, custom, ArticleList, ArticleDetail, TagsView, about

urlpatterns = [

    # 首页调用IndexView
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^index.html/$', IndexView.as_view(), name='index'),  # .html 处理方式不对哦

    # 使用(?P<>\d+)的形式捕获值给<>中得参数,比如(?P<article_id>\d+),当访问/blog/article/3时,
    # 将会将3捕获给article_id,这个值会传到views.ArticleDetailView,这样我们就可以判断展示哪个Article了
    url(r'article/(?P<article_id>\d+)$', ArticleDetailView.as_view(), name='detail'),
    url(r'category/(?P<cate_id>\d+)$', CategoryView.as_view(), name='category'),
    url(r'^custom/$', custom),
    url(r'^tags/$', TagsView.as_view(), name='tags'),
    url(r'^about/$', about, name='about'),

    # api
    url(r'api/v1/articles$', ArticleList.as_view()),
    url(r'api/v1/articles/(?P<article_id>\d+)$', ArticleDetail.as_view()),

]
示例#18
0
from django.contrib import admin
from django.urls import path

from blog.views import (ArticleListView, ArticleDetailView, ArticleCreateView,
                        ArticleUpdateView, ArticleDeleteView)

app_name = 'blog'
urlpatterns = [
    path('', ArticleListView.as_view(), name='article-list'),
    path('<int:my_id>/', ArticleDetailView.as_view(), name='article-detail'),
    # Generic detail view ArticleDetailView must be called with either an object pk or a slug in the URLconf.
    path('create/', ArticleCreateView.as_view(), name='article-create'),
    path('<int:id>/update/',
         ArticleUpdateView.as_view(),
         name='article-update'),
    path('<int:id>/delete/',
         ArticleDeleteView.as_view(),
         name='article-delete')
]
示例#19
0
文件: urls.py 项目: azamat1977/blog
                        ArticleDeleteView, ArticleDetailView,
                        CategoryCreateView, CategoryDeleteView,
                        CategoryUpdateView, CategoryDetailView, login, logout,
                        register)
from django.views.generic import TemplateView
from django.views.decorators.cache import cache_page

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', index),
    # urls_for_article
    path('article/', article_listview),
    path('article/create/', ArticleCreateView.as_view()),
    path('article/<int:pk>/delete/', ArticleDeleteView.as_view()),
    path('article/<int:pk>/update/', ArticleUpdateView.as_view()),
    path('article/<int:pk>/', ArticleDetailView.as_view()),

    # path('article/post_form/', post_form),

    # urls_for_category
    path('category/', category_listview),
    path('category/create/', CategoryCreateView.as_view()),
    path('category/<int:pk>/delete/', CategoryDeleteView.as_view()),
    path('category/<int:pk>/update/', CategoryUpdateView.as_view()),
    path('category/<int:pk>/', CategoryDetailView.as_view()),

    # urls_for_login_logout
    path('login/', login),
    path('logout/', logout),
    path('register/', register),
]