Example #1
0
from blogs.api import BlogsAPI, PostsAPI, PostDetailAPI, UserBlogAPI
from blogs.views import LatestPostsView, BlogsView, UserBlogView, PostDetailView, NewPostView
from users.api import UsersAPI, UserDetailAPI
from users.views import LoginView, SignupView, logout

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', LatestPostsView.as_view(), name='index'),
    url(r'^blogs/$', BlogsView.as_view(), name='blogs'),
    url(r'^blogs/(?P<username>[0-9a-zA-Z_-]+)/$',
        UserBlogView.as_view(),
        name='user_blog'),
    url(r'^blogs/(?P<username>[0-9a-zA-Z_-]+)/(?P<pk>[0-9]+)/$',
        PostDetailView.as_view(),
        name='post_detail'),
    url(r'^new-post/$', NewPostView.as_view(), name='new_post'),
    url(r'^login/$', LoginView.as_view(), name='login'),
    url(r'^signup/$', SignupView.as_view(), name='signup'),
    url(r'^logout/$', logout, name='logout'),

    # API Users
    url(r'^api/1.0/users/$', UsersAPI.as_view(), name='users_api'),
    url(r'^api/1.0/users/(?P<pk>[0-9]+)/$',
        UserDetailAPI.as_view(),
        name='user_detail_api'),

    # API Blogs
    url(r'^api/1.0/blogs/$', BlogsAPI.as_view(), name='blogs_api'),
    url(r'^api/1.0/blogs/(?P<pk>[0-9]+)/$',
        UserBlogAPI.as_view(),
        name='user_blog_api'),
Example #2
0
router = DefaultRouter()
router.register("users", UserViewSet, base_name="users_api")
router.register("posts", PostViewSet, base_name="posts_api")

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    # blogs
    url(r'^$', posts_list, name='posts_list'),
    url(r'^blogs/$', blogs_list, name='blogs_list'),
    url(r'^blogs/(?P<username>[0-9a-zA-Z]+)/$',
        user_posts_list,
        name="user_posts_list"),
    url(r'^blogs/(?P<username>[0-9a-zA-Z]+)/(?P<post_pk>[0-9]+)$',
        user_post_detail,
        name="user_post_detail"),
    url(r'^new-post$', NewPostView.as_view(), name="new_post"),
    # login
    url(r'^login$', LoginView.as_view(), name='login'),
    url(r'^logout$', logout, name='logout'),
    url(r'^signup$', SignupView.as_view(), name='signup'),

    # api de usuarios y posts
    url(r'^api/1.0/', include(router.urls)),
    # api de blogs
    url(r'^api/1.0/blogs/$', BlogsAPI.as_view(), name='blogs_api'),
    # api de posts
    url(r'^api/1.0/blogs/(?P<username>[0-9a-zA-Z]+)/$',
        PostViewSet.as_view({'get': 'list'}),
        name='user_posts_list_api')
]
Example #3
0
"""
from django.conf.urls import url, include
from django.contrib import admin
from rest_framework.routers import DefaultRouter

from blogs.views import lastest_posts, blogs_list, blog_detail, post_detail, NewPostView
from users.views import LoginView, SignUpView, LogoutView

from users.api import UserViewSet
from blogs.api import BlogViewSet, PostViewSet

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")
router.register(r'blogs/(?P<blog_id>[0-9]+)/posts', PostViewSet)

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', lastest_posts, name="index"),
    url(r'^blogs/?$', blogs_list, name="blog_list"),
    url(r'^blogs/(?P<slug>[\w.@+-]+)/?$', blog_detail, name="blog_detail"),
    url(r'^blogs/(?P<slug>[\w.@+-]+)/(?P<post_pk>[0-9]+)/?$', post_detail, name="post_detail"),
    url(r'^new_post', NewPostView.as_view(), name="new_post"),
    url(r'^login',LoginView.as_view(), name="login"),
    url(r'^logout',LogoutView.as_view(), name="logout"),
    url(r'^signup',SignUpView.as_view(), name="signup"),

    #api
    url(r'^api/1.0/', include(router.urls)),
]
Example #4
0
router = SimpleRouter()
router.register(r'blogs', BlogViewSet, basename='blogs_api')
router.register(r'blogs-detail', BlogDetailViewSet, basename='blogs_detail_api')
router.register(r'users', UsersViewSet, basename='users_api')
router.register(r'posts', PostAPIViewSet, basename='posts_api')


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

    # api
    path('api/', include(router.urls)),

    # auth
    path('login', LoginView.as_view(), name="login"),
    path('logout', LogoutView.as_view(), name="logout"),
    path('sign-up', SignUpView.as_view(), name="sign_up"),

    # blogs
    path('blogs/', BlogsListView.as_view(), name="blogs"),
    path('blogs/<str:username>/', BlogDetailView.as_view(), name="blog_detail"),
    path('blogs/<str:username>/<int:pk>', PostDetailView.as_view(), name="post_detail"),

    # posts
    path('new-post', NewPostView.as_view(), name="new_post"),

    # home
    path('', LatestPostsView.as_view(), name="home"),

]
Example #5
0
from users.views import LoginView, logout, SignupView

router = DefaultRouter()
router.register("users", UsersAPI, base_name="users_api")

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', home, name="home"),
    url(r'^blogs/$', blogs_list, name="blogs_list"),
    url(r'^blogs/(?P<username>[a-zA-Z0-9_]+)/?$',
        blog_detail,
        name='blog_detail'),
    url(r'^blogs/(?P<username>[a-zA-Z0-9_]+)/(?P<post_id>[0-9]+)/?$',
        post_detail,
        name='post_detail'),
    url(r'^new-post$', NewPostView.as_view(), name="post_new"),
    url(r'^reply-post/(?P<pk>[0-9]+)/$',
        NewPostView.as_view(),
        name="reply_post"),
    url(r'^login$', LoginView.as_view(), name="login"),
    url(r'^signup$', SignupView.as_view(), name="signup"),
    url(r'^logout$', logout, name="logout"),

    # API
    url(r'^api/1.0/', include(router.urls)),
    url(r'^api/1.0/blogs/$', BlogsAPI.as_view(), name='blogs_api'),
    url(r'^api/1.0/blogs/(?P<pk>[0-9]+)/$',
        BlogPostsAPI.as_view(),
        name='blogs_post_api'),
    url(r'^api/1.0/posts/$', PostsAPI.as_view(), name='posts_api'),
    url(r'^api/1.0/posts/(?P<pk>[0-9]+)/$',
Example #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
from django.contrib import admin
from django.contrib.auth.decorators import login_required

from blogs.views import PostList, BlogList, NewPostView, PostDetail
from users.views import LoginView, LogoutView

urlpatterns = [
    url(r'^$', PostList.as_view(), name="posts_list"),
    url(r'^admin/', admin.site.urls),
    url(r'^login$', LoginView.as_view(), name="login"),
    url(r'^logout$', LogoutView.as_view(), name='logout'),
    url(r'^blogs/$', BlogList.as_view(), name="blog_list"),
    url(r'^blogs/(?P<username>[\w.@+-]+)/$',
        PostList.as_view(),
        name="posts_list"),
    #url(r'^blogs/(?P<username>[a-zA-Z0-9_]+)/?$', BlogDetail.as_view(), name="blog_detail"),
    url(r'^blogs/(?P<username>[a-zA-Z0-9_]+)/(?P<pk>[0-9]+)/?$',
        login_required(PostDetail.as_view()),
        name="post_detail"),
    url(r'^blogs/new-post/?$',
        login_required(NewPostView.as_view()),
        name="new_post"),
    #url(r'^posts/(?P<post_pk>[0-9]+)$', posts_detail, name="posts_detail"),
]
Example #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)),
]
Example #8
0
from users.views import LoginView, LogoutView, SignupView

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

    # Users
    path('login', LoginView.as_view(), name='login'),
    path('logout', LogoutView.as_view(), name='logout'),
    path('signup', SignupView.as_view(), name='signup'),

    # Blogs
    path('blogs/', BlogList.as_view(), name='blog_list'),
    path('blogs/<str:username>/', BlogDetail.as_view(), name='blog_detail'),
    path('blogs/<str:username>/<int:pk>',
         BlogPostDetail.as_view(),
         name='blog_post_detail'),
    path('new-post/', NewPostView.as_view(), name='new_post'),
    path('', LatestPost.as_view(), name='home'),

    # API
    path('apiv1/users/<int:pk>/',
         UserDetailAPI.as_view(),
         name='user_detail_api'),
    path('apiv1/users/', UsersAPI.as_view(), name='users_api'),
    path('apiv1/posts/<int:pk>',
         PostDetailAPI.as_view(),
         name='post_detail_api'),
    path('apiv1/posts/', PostsAPI.as_view(), name='posts_api'),
    path('apiv1/blogs/', BlogsAPI.as_view(), name='blogs_api')
]
# -*- coding: utf-8 -*-
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from blogs.views import HomeView, NewPostView, BlogListView, BlogDetailView, PostDetailView

urlpatterns = [
    #Blogs URLs
    url(r'^$', HomeView.as_view(), name='blogs_home'),
    url(r'^new-post/$', login_required(NewPostView.as_view()), name='create_post'),
    url(r'^blogs/$', BlogListView.as_view(), name='blogs_list'),
    url(r'^blogs/(?P<username>[a-z0-9_-]{3,16})$', BlogDetailView.as_view(), name='blog_detail'),
    url(r'^blogs/(?P<username>[a-z0-9_-]{3,16})/(?P<pk>[0-9]+)$', PostDetailView.as_view(), name='post_detail')
]