def _submitPostForm(request, post_pk=None): if request.method == "POST": form = PostForm(request.POST) if form.is_valid(): if post_pk != None: response = PostList.as_view()(request, post_pk) else: response = PostList.as_view()(request) # makes post call to API return response
from rest_framework_jwt.views import obtain_jwt_token from django.urls import path,include from api.views import fav_delete,fav_details,PostsByUser,Favorites,PostList,CategoryList,PostListPublished, CategoryDetails, CategoryPostList, UserViewSet,VacancyList,post_details,published_list from rest_framework_jwt.views import obtain_jwt_token from rest_framework import routers router = routers.DefaultRouter() router.register('users',UserViewSet) urlpatterns = [ path(r'', include(router.urls)), path('login/', obtain_jwt_token), path('admin/', PostList.as_view()), path('admin/<int:post_id>/', post_details), path('posts/', PostListPublished.as_view()), path('posts/<int:post_id>/', post_details), path('fav/', Favorites.as_view()), path('fav/<int:author_id>/', fav_details), path('profile/<int:user_id>/', PostsByUser), path('fav/<int:post_id>/<int:author_id>/', fav_delete), path('categories/', CategoryList.as_view()), path('categories/<int:pk>/', CategoryDetails.as_view()), path('categories/<int:pk>/posts/', CategoryPostList.as_view()) ]
from django.contrib import admin from rest_framework.urlpatterns import format_suffix_patterns from api.views import PostList, PostDetail, PublicPostDetail, ProfileDetail admin.autodiscover() if settings.DEBUG: urlpatterns = patterns('django.views.static', url(r'^static/(?P<path>.*)$', 'serve', {'document_root': '/tmp/shortdiary-static/', 'show_indexes': True }), url(r'^asset/(?P<path>.*)$', 'serve', {'document_root': '/tmp/shortdiary-asset/', 'show_indexes': True }), ) else: urlpatterns = patterns('') api_patterns= format_suffix_patterns(patterns('', url(r'^posts/$', PostList.as_view(), name="api-post-list"), url(r'^posts/(?P<pk>\d+)/$', PostDetail.as_view(), name='api-post-detail'), url(r'^public/$', PublicPostDetail.as_view(), name='api-public-post'), url(r'^profile$', ProfileDetail.as_view(), name='api-profile-detail'), ), allowed=["json", "html"]) urlpatterns += patterns('', url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^i18n/setlang/(?P<language>[a-z]+)', 'diary.views.switch_language'), url(r'^accounts/login/$', 'diary.views.login'), url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}), url(r'^accounts/signup/$', 'diary.views.sign_up'), url(r'^accounts/settings/$', 'diary.views.account_settings'),
from api import views from rest_framework_jwt.views import obtain_jwt_token # from graphene_django.views import GraphQLView # from schema import schema urlpatterns = [ path('admin/', admin.site.urls), path('register/', RegisterAPIView.as_view(), name='register'), path('login/', obtain_jwt_token, name='login'), # path('graphql', GraphQLView.as_view(graphiql=True, schema=schema)), # path('category/', CategoriesList.as_view(), name='category-list'), path('selling/brands/', SellingBrands.as_view(), name='sellingBrands-list'), path('regular/posts/', PostList.as_view(), name='regular-posts'), path('special/posts', SpecialPostList.as_view(), name='special-posts'), path('all/posts', AllSellingPostList.as_view(), name='all-posts'), path('brand/posts/<int:brand_id>', BrandsPosts.as_view(), name='brand-posts'), path('brand/classes/<int:brand_id>', BrandClass.as_view(), name='brand-classes'), path('post/views/<int:post_id>', ViewsCount.as_view(), name='post-views'), path('latest/posts/', LatestPosts.as_view(), name='latest-posts'), path('most/viewed/posts/', MostViewed.as_view(), name='most-viewed-posts'), ] if settings.DEBUG: urlpatterns += static(settings.STATIC_URL,
from django.conf.urls import include, url from django.urls import path from rest_framework import routers from api.views import PostList, PostDetail from api.viewsets import PostViewSet router = routers.DefaultRouter() router.register('postviewset', PostViewSet, 'posts') app_name = 'api' urlpatterns = [ path('', include(router.urls)), url(r'posts/$', PostList.as_view()), url(r'^posts/(?P<pk>[0-9]+)/$', PostDetail.as_view()), ]
# Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. users_urls = [ url(r'^$', UserList.as_view(), name='user-list'), url(r'^(?P<username>[0-9a-zA-Z_-]+)/$', UserDetail.as_view(), name='user-detail'), url(r'^(?P<username>[0-9a-zA-Z_-]+)/posts/$', UserPostList.as_view(), name='userpost-list'), ] posts_urls = [ url(r'^$', PostList.as_view(), name='post-list'), url(r'^(?P<pk>\d+)/photos/$', PostPhotoList.as_view(), name='postphoto-list'), url(r'^(?P<pk>\d+)/$', PostDetail.as_view(), name='post-detail'), ] photos_urls = [ url(r'^(?P<pk>\d+)/$', PhotoDetail.as_view(), name='photo-detail'), url(r'^$', PhotoList.as_view(), name='photo-list'), ] urlpatterns = [ url(r'^users/', include(users_urls)), url(r'^posts/', include(posts_urls)), url(r'^photos/', include(photos_urls)),
from django.conf.urls import patterns, url from blog.views import post, post_edit, post_new, post_delete from api.views import PostList, PostDetail urlpatterns = patterns("", url(r"^blog/$", PostList.as_view(), name="post-list"), url(r"^blog/(?P<pk>\d+)$", PostDetail.as_view(), name="post-detail"), )
from django.conf.urls import url, include from api.views import UserList, PostDetail, PostList, UserPostList, UserDetail, PostPhotoList, PhotoList, PhotoDetail # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. users_urls = [ url(r'^$', UserList.as_view(), name='user-list'), url(r'^(?P<username>[0-9a-zA-Z_-]+)/$', UserDetail.as_view(), name='user-detail'), url(r'^(?P<username>[0-9a-zA-Z_-]+)/posts/$', UserPostList.as_view(), name='userpost-list'), ] posts_urls = [ url(r'^$', PostList.as_view(), name='post-list'), url(r'^(?P<pk>\d+)/photos/$', PostPhotoList.as_view(), name='postphoto-list'), url(r'^(?P<pk>\d+)/$', PostDetail.as_view(), name='post-detail'), ] photos_urls = [ url(r'^(?P<pk>\d+)/$', PhotoDetail.as_view(), name='photo-detail'), url(r'^$', PhotoList.as_view(), name='photo-list'), ] urlpatterns = [ url(r'^users/', include(users_urls)), url(r'^posts/', include(posts_urls)), url(r'^photos/', include(photos_urls)), ]
from django.conf.urls import url from api.views import UserList, UserDetail, PostDetail, PostList, CartrigesList, CartridgieDetail, DispatchList, \ DispatchDetail urlpatterns=[ url(r'^users/$', UserList.as_view(), name='user-list'), url(r'^users/(?P<pk>\d+)/$', UserDetail.as_view(), name='user-detail'), url(r'^post-offices/$', PostList.as_view(), name='postoficce-list'), url(r'^post-offices/(?P<index>\d+)/$', PostDetail.as_view(), name='postoficce-detail'), url(r'^cartridgies/$', CartrigesList.as_view(), name='cartridgie-list'), url(r'^cartridgies/(?P<model>\d+)/$', CartridgieDetail.as_view(), name='cartridgie-detail'), url(r'^dispatchs/$', DispatchList.as_view(), name='dispatch-list'), url(r'^dispatchs/(?P<pk>\d+)/$', DispatchDetail.as_view(), name='dispatch-detail'), ]
from django.conf.urls import include, url from api.views import PostList, PostDetail urlpatterns = [ url(r'^posts/$', PostList.as_view(), name='post_list_page'), url(r'^posts/(?P<pk>[0-9]+)$', PostDetail.as_view(), name='post_detail_page'), url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')) ]
from django.urls import path from api.views import PostList, PostDetail urlpatterns = [ path('', PostList.as_view(), name='userpost'), path('<int:pk>', PostDetail.as_view(), name='userpost-home') ]
from django.urls import path from api.views import PostList, PostDetail urlpatterns = [ path('', PostList.as_view(), name='post_list'), path('<int:pk>/', PostDetail.as_view(), name='post_detail') ]
Class-based views 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.conf.urls import url from django.contrib import admin from django.urls import path from api.views import (BlogPostCommentList, CoinbaseTransactionList, DownloadResume, Photos, PostList, UserList) from mysite.views import Index urlpatterns = [ path('', Index.as_view()), path('admin/', admin.site.urls), # path('personal/', include('personal.urls')), path('personal/contact/', Index.as_view()), path('api/users', UserList.as_view()), path('api/posts', PostList.as_view()), path('api/posts/comments', BlogPostCommentList.as_view()), path('api/coinbase/transactions', CoinbaseTransactionList.as_view()), # path('api/coinbase/prices', CoinbasePriceList.as_view()), path('api/photos', Photos.as_view()), path('resume', DownloadResume), # url(r'^.*', TemplateView.as_view(template_name="home.html"), name="home") url(r'^.*', Index.as_view(), name="home") ]
from django.urls import path from api.views import PostCreate, PostList, PostDetail urlpatterns = [ path('blog/', PostList.as_view(), name='page_list'), path('blog/<int:pk>', PostDetail.as_view(), name='page_detail'), path('blog/new', PostCreate.as_view(), name='new_page'), ]
from django.urls import path from api.views import Index, UserCreate, PostList, PostListAuthorPosts, PostCreate, PostDetail, CreateComment from rest_framework.authtoken import views urlpatterns = [ path("", Index.as_view(), name='index'), path("posts/", PostList.as_view(), name='posts'), path("author-posts/", PostListAuthorPosts.as_view(), name='author-posts'), path("post-create/", PostCreate.as_view(), name='post-create'), path("post-detail/<int:pk>/", PostDetail.as_view(), name="post-detail" ), path("create-comment/<int:pk>/", CreateComment.as_view(), name="create-comment"), path("create-user/", UserCreate.as_view(), name='create user'), path('login/', views.obtain_auth_token, name='login'), ]