#-*- coding: utf-8 -*-
__author__ = 'daviddetena'

# -*- coding: utf-8 -*-
from django.conf.urls import url
from blogs.views import HomeView, BlogListView, BlogDetailView, PostDetailView, CreateView

urlpatterns = [
    # Blogs URLs
    url(r'^$', HomeView.as_view(), name='home'),
    url(r'^blogs/$', BlogListView.as_view(), name='blog_list'),
    url(r'^blogs/(?P<username>[a-z]+)$', BlogDetailView.as_view(), name='blog_detail'),
    url(r'^blogs/(?P<username>[a-z]+)/(?P<pk>[0-9]+)', PostDetailView.as_view(), name='post_detail'),
    url(r'^new-post/$', CreateView.as_view(), name='post_create'),
]
示例#2
0
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from rest_framework_extensions.routers import NestedRouterMixin

from blogs.api import BlogsViewSet
from blogs.views import NewBlogView, BlogListView, UserBlogsView, BlogView
from posts.api import PostsViewSet


class NestedDefaultRouter(NestedRouterMixin, DefaultRouter):
    # Use NestedRouterMixin to have posts endpoints nested into blogs
    pass


router = NestedDefaultRouter()
blogs_router = router.register('blogs', BlogsViewSet)
blogs_router.register(
    'posts', PostsViewSet,
    base_name='blog-posts',
    parents_query_lookups=['blogs'])

urlpatterns = [
    path('blogs/', BlogListView.as_view(), name='blogs'),
    path('blogs/new/', NewBlogView.as_view(), name='new-blog'),
    path('users/<slug:username>/', UserBlogsView.as_view(), name='user-blogs'),
    path('blogs/<slug:slug>/', BlogView.as_view(), name='blog'),

    # API
    path('api/1.0/', include(router.urls)),
]
示例#3
0
文件: urls.py 项目: pre22/Trench-Blog
from blogs.views import (
    BlogListView,
    AboutPageView,
    ContactPageView,
    BlogCreateView,
    BlogDetailView,
    BlogUpdateView,
    BlogDeleteView,
    ProfilePage,
    ProfilePageUpdate,
    CreateCommentView,
)
from django.contrib.auth.decorators import login_required

urlpatterns = [
    path('', BlogListView.as_view(), name='home'),
    path('post/<int:pk>/', BlogDetailView.as_view(), name='post_detail'),
    path('post/new', login_required(BlogCreateView.as_view()),
         name='post_new'),
    path('post/<int:pk>/edit/',
         login_required(BlogUpdateView.as_view()),
         name='post_edit'),
    path('post/<int:pk>/delete/',
         login_required(BlogDeleteView.as_view()),
         name='post_delete'),
    path('post/<int:pk>/comment/', CreateCommentView.as_view(),
         name="comment"),
    path('about/', AboutPageView.as_view(), name='about'),
    path('contact/', ContactPageView.as_view(), name='contact'),
    path('dashboard/<int:pk>/',
         login_required(ProfilePage.as_view()),
示例#4
0
from users.api import UserViewSet
from blogs.api import PostListAPI, PostDetailAPI, BlogListAPI, CreatePostViewSet
from django.contrib.auth.decorators import login_required

# APIRouter

router = DefaultRouter()

router.register(r'api/1.0/users', UserViewSet, base_name='user')

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', HomeView.as_view(), name='home'),

    # Blogs
    url(r'^blogs/$', BlogListView.as_view(), name='blogs_list'),
    url(r'^blogs/(?P<user>[A-Za-z0-9]+)$',
        BlogListDetailView.as_view(),
        name='blog_user'),
    url(r'^blogs/(?P<user>[A-Za-z0-9]+)/(?P<pk>[0-9]+)$',
        PostDetailView.as_view(),
        name='post_detail'),

    # Posts
    url(r'^new-post$', CreatePostView.as_view(), name='new_post'),

    # Blogs API
    url(r'^api/1.0/blogs/$', BlogListAPI.as_view(), name='post_list_api'),
    url(r'^api/1.0/blogs/(?P<user>[A-Za-z0-9]+)$',
        PostListAPI.as_view(),
        name='blog_user_api'),
示例#5
0
from django.urls import path

from blogs.api import BlogsListApiView
from blogs.views import BlogListView
from posts.views import PostListView

urlpatterns = [
    path('', PostListView.as_view(), name='home'),
    path('blogs', BlogListView.as_view(), name='blog_list'),

    #API Routes
    path('api/1.0/blogs', BlogsListApiView.as_view(), name='API_blogs_view')
]
示例#6
0
from blogs.views import BlogListView, CreateBlogView
from posts.api import PostViewSet
from posts.views import PostDetailView, BlogDetailView, CreatePostView, HomeView
from users.api import UsersAPI, UserDetailAPI
from users.views import LoginView, LogoutView, CreateUserView

router = DefaultRouter()
router.register('posts', PostViewSet)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', HomeView.as_view(), name='home'),
    path('blogs/<str:username>/<int:pk>',
         PostDetailView.as_view(),
         name='post_detail'),
    path('blogs/', BlogListView.as_view()),
    path('blogs/<str:username>/', BlogDetailView.as_view()),
    path('login', LoginView.as_view(), name='login'),
    path('logout', LogoutView.as_view(), name='logout'),
    path('new-post', CreatePostView.as_view(), name='new_post'),
    path('new-blog', CreateBlogView.as_view(), name='new_blog'),
    path('signup', CreateUserView.as_view(), name='new_user'),

    # API URLs
    path('api/v1/', include(router.urls)),
    path('api/v1/users/', UsersAPI.as_view(), name='api-user'),
    path('api/v1/users/<int:pk>/',
         UserDetailAPI.as_view(),
         name='api-user-detail'),
    path('api/v1/blogs/', BlogListAPI.as_view(), name='api-blogs'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
示例#7
0
from blogs.api import BlogViewSet, PostViewSet
from blogs.views import blogs_list, posts_list, post_detail, NewPostView, NewBlogView, PostListView, BlogListView, \
    post_detail_blog
from users.api import UserViewSet
from users.views import LoginView, logout, RegisterView

router = DefaultRouter()
router.register("users", UserViewSet, base_name="users_api")
router.register("blogs", BlogViewSet, base_name="blogs_api")
router.register("posts", PostViewSet, base_name="posts_api")

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^blogs$', blogs_list, name="blogs_list"),
    url(r'^posts/new$', NewPostView.as_view(), name="new_post"),
    url(r'^posts/mis-posts$', PostListView.as_view(), name="mis_posts"),
    url(r'^posts/mis-blogs$', BlogListView.as_view(), name="mis_blogs"),
    url(r'^blogs/new$', NewBlogView.as_view(), name="new_blog"),
    url(r'^blogs/(?P<blog_name>[a-zA-Z-]+)/(?P<post_pk>[0-9]+)$',
        post_detail,
        name="post_detail"),
    url(r'^blogs/(?P<blog_pk>[0-9]+)/$',
        post_detail_blog,
        name="post_from_blog"),
    url(r'^login$', LoginView.as_view(), name="login"),
    url(r'^sign-up', RegisterView.as_view(), name="registro"),
    url(r'^logout$', logout, name="logout"),
    url(r'^$', posts_list, name="home"),
    url(r'^api/1.0/', include(router.urls)),
]
示例#8
0
The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.9/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. 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 patterns, include, url
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin

from blogs.views import BlogListView, BlogDetailView
urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^(?P<slug>[-\w]+)/$', BlogDetailView.as_view(), name='blog-detail'),
    url(r'^ckeditor/', include('ckeditor_uploader.urls')),
    url(r'^$', BlogListView.as_view(), name='blogs-list'),

]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

urlpatterns += patterns('',
          (r'^static/(?P<path>.*)$', 'django.views.static.serve', {
          'document_root': settings.STATIC_ROOT}))
示例#9
0
"""
from django.contrib import admin
from django.urls import path
from blogs import views as blogs_views
from users import views as users_views
from blogs.views import BlogCreateView, BlogListView, BlogDetailView, BlogUpdateView, BlogDeleteView

from django.contrib.auth import views as auth_views

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

urlpatterns = [
    path('', blogs_views.index, name="index"),
    path('post/create/', BlogCreateView.as_view(), name="create"),
    path('post/list/', BlogListView.as_view(), name="list"),
    path('post/detail/<int:pk>/', BlogDetailView.as_view(), name="detail"),
    path('post/<int:pk>/update/', BlogUpdateView.as_view(), name="update"),
    path('post/<int:pk>/delete/', BlogDeleteView.as_view(), name="delete"),
    path('user/register/', users_views.register, name="register"),
    path('user/login/',
         auth_views.LoginView.as_view(template_name="users/login.html"),
         name="login"),
    path('user/logout/',
         auth_views.LogoutView.as_view(template_name="users/logout.html"),
         name="logout"),
    path('password/reset/',
         auth_views.PasswordResetView.as_view(
             template_name="users/password_reset.html"),
         name="password_reset"),
    path('password/reset/done/',
示例#10
0
from django.urls import path

from blogs.api import BlogListAPI, PostListAPI, PostDetailAPI
from blogs.views import LatestPostsView, BlogListView, PostListByAuthorView, PostDetailView, CreatePostView
from users.api import UserListAPI, UserDetailAPI
from users.views import LoginView, LogoutView, SignUpView

urlpatterns = [
    path('admin/', admin.site.urls),

    path('login/', LoginView.as_view(), name="login_page"),
    path('logout/', LogoutView.as_view(), name="logout_page"),
    path('singup/', SignUpView.as_view(), name="signup_page"),

    path('new-post/', CreatePostView.as_view(), name="create_post_page"),

    path('blogs/<str:author>/<int:pk>', PostDetailView.as_view(), name="post_detail_page"),
    path('blogs/<str:author>/', PostListByAuthorView.as_view(), name="list_posts_page"),
    path('blogs/', BlogListView.as_view(), name="list_blogs_page"),
    path('', LatestPostsView.as_view(), name="home_page"),

    # API REST
    path('api/1.0/users/<int:pk>', UserDetailAPI.as_view(), name="api_user_detail"),
    path('api/1.0/users/', UserListAPI.as_view(), name="api_users_list"),

    path('api/1.0/blogs/<str:author>/<int:pk>', PostDetailAPI.as_view(), name="api_post_detail"),
    path('api/1.0/blogs/<str:author>/', PostListAPI.as_view(), name="api_blogs_author"),
    path('api/1.0/blogs/', BlogListAPI.as_view(), name="api_blogs_list")
]