from django.conf import settings from django.urls import path from posts import views from posts import views as post_views from users import views as users_views from users.api import UsersAPI, UserDetailAPI from posts.api import PostsAPI, PostsDetailAPI urlpatterns = [ path('admin/', admin.site.urls), path('', post_views.PostsFeedView.as_view(), name='feed'), path('posts/new/', views.CreatePostView.as_view(), name='create_post'), path('posts/<str:username>/<int:pk>/', views.PostDetailView.as_view(), name='post_detail'), path('blogs/<str:username>', users_views.UserDetailView.as_view(), name='user_blog'), path('login/', users_views.LoginView.as_view(), name='login'), path('logout', users_views.LogoutView.as_view(), name='logout'), path('signup', users_views.SignupView.as_view(), name='signup'), # API path('api/users/', UsersAPI.as_view(), name='users_api'), path('api/users/<int:pk>', UserDetailAPI.as_view(), name='user_detail'), path('api/posts/', PostsAPI.as_view(), name='posts_api'), path('api/posts/<int:pk>', PostsDetailAPI.as_view(), name='posts_detail'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
url(r'^$', post_list, name="post_list"), url(r'^blogs/$', blog_list, name="blog_list"), url(r'^blogs/(?P<user_name>[a-zA-Z0-9]+)/$', user_posts, name="user_posts"), url(r'^blogs/(?P<user_name>[a-zA-Z0-9]+)/(?P<post_pk>[0-9]+)/$', post_detail, name="post_detail"), url(r'^new-post/$', NewPostView.as_view(), name="post_new"), #Users url(r'^login$', LoginView.as_view(), name="login"), url(r'^logout$', logout, name="logout"), url(r'^signup$', UserView.as_view(), name="signup"), #API Users. Me permiten. La primera consultar los usuarios, y la segunda ver el detalle, borrar o actualizar el usuario con ese id. 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 Blogs. Endpoints para listado de blogs, leer articulos de un blog y para crear, modificar y borrar posts. url(r'^api/1.0/blogs/$', BlogListAPI.as_view(), name="bloglist_api"), url(r'^api/1.0/blogs/(?P<pk>[0-9]+)/$', PostListAPI.as_view(), name="postlist_api"), url(r'^api/1.0/newposts/$', NewPostAPI.as_view(), name="newpost_api"), url(r'^api/1.0/postdetail/(?P<pk>[0-9]+)/$', PostDetailAPI.as_view(), name="post_detail") ]
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'), # API Posts url(r'^api/1.0/posts/$', PostsAPI.as_view(), name='posts_api'), url(r'^api/1.0/posts/(?P<pk>[0-9]+)/$', PostDetailAPI.as_view(), name='post_detail_api')
api_path = 'api/v1' 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/<str:username>/<int:pk>', PostDetailView.as_view(), name='post_detail'), path('blogs/<str:username>', LatestPostsView.as_view(), name='user_blog'), path('blogs', ListView.as_view(), name='list_blogs'), # Posts path('new-post', CreatePostView.as_view(), name='create_post'), path('', LatestPostsView.as_view(), name='home'), # API path('{0}/blogs'.format(api_path), BlogsAPI.as_view(), name='blogs_api'), path('{0}/users/<int:pk>'.format(api_path), UserAPI.as_view(), name='user_api'), path('{0}/users'.format(api_path), UsersAPI.as_view(), name='users_api'), path('{0}/posts/<int:pk>'.format(api_path), PostAPI.as_view(), name='post_api'), path('{0}/posts'.format(api_path), PostsAPI.as_view(), name='posts_api'), ]
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)