# -*- coding: utf-8 -*- from django.conf.urls import patterns, include, url from rest_framework.urlpatterns import format_suffix_patterns from api.views import MessagesList, CategoryList, CategoryDetail,\ MapMessageList urlpatterns = patterns('api.views', url(r'^$', 'api_root'), url(r'^messages/$', MessagesList.as_view(), name='messages-list'), url(r'^categories/$', CategoryList.as_view(), name='cat-list'), url(r'^categories/(?P<pk>\d+)/$', CategoryDetail.as_view(), name='category-detail'), url(r'^internal/mapmessages/$', MapMessageList.as_view()), ) urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'api'])
from django.urls import path from api.views import CategoryList, ProductList, CategoryDetail, BasketList from api import views urlpatterns = [ path('categories', CategoryList.as_view()), path('products', ProductList.as_view()), path('category/<int:pk>', CategoryDetail.as_view()), path('basket', BasketList.as_view()), path('login', views.login), path('logout', views.logout), path('history', views.get_order_history), path('order', views.make_order) ]
from django.urls import path from rest_framework_jwt.views import obtain_jwt_token from api.views import CategoryList, CategoryDetail, author_list, author_detail, author_products, top_products,\ category_products, Products_Detail, Products_List urlpatterns = [ path('login/', obtain_jwt_token), path('categories', CategoryList.as_view()), #-done path('categories/<int:pk>', CategoryDetail.as_view()), #-done path('categories/<int:pk>/products', category_products), path('authors', author_list), #-done path('authors/<int:pk>', author_detail), #-done path('authors/<int:pk>/products', author_products), #-done path('products', Products_List.as_view()), path('products/<int:pk>', Products_Detail.as_view()), #-put path('products/top', top_products) ]
from api.views import CategoryDetail, SubcategoryDetail, UserList, UserDetail, \ CityList, CategoryList, SubCategoryList, CityDetail, ListCreateListing, \ DetailUpdateDeleteListing from rest_framework.authtoken import views from django.conf.urls import url, include urlpatterns = [ url(r'^api-token-auth/$', views.obtain_auth_token), url(r'^docs/', include('rest_framework_swagger.urls')), url(r'^users/$', UserList.as_view(), name="list_user"), url(r'^users/(?P<pk>\d+)/$', UserDetail.as_view(), name="detail_user"), url(r'^cities/(?P<pk>\d+)/$', CityDetail.as_view(), name="detail_city"), url(r'^cities/$', CityList.as_view(), name="city_list"), url(r'^categories/$', CategoryList.as_view(), name="list_category"), url(r'^categories/(?P<pk>\d+)/$', CategoryDetail.as_view(), name="detail_category"), url(r'^subcategories/$', SubCategoryList.as_view(), name="subcategory_list"), url(r'^subcategories/(?P<pk>\d+)/$', SubcategoryDetail.as_view(), name="subdetail_category"), url(r'^classifieds/$', ListCreateListing.as_view(), name="list_create_listing"), url(r'^classifieds/(?P<pk>\d+)/$', DetailUpdateDeleteListing.as_view(), name="detail_update_delete_listing") ]
from django.conf.urls import url, include from django.contrib import admin from api.views import ProductList, ProductDetail, CategoryList, CategoryDetail, OrderList urlpatterns = [ url(r'^products/$', ProductList.as_view()), url(r'^products/(?P<pk>[0-9]+)/$', ProductDetail.as_view()), url(r'^categories/$', CategoryList.as_view()), url(r'^categories/(?P<pk>[0-9]+)/$', CategoryDetail.as_view()), url(r'^orders/$', OrderList.as_view()), ]
from api.views import CityList, CategoryList, SubCategoryList, \ ListCreateAdvertisement, DetailUpdateDeleteAdvertisement, CityDetail, \ CategoryDetail, SubCategoryDetail, UserList, UserDetail from django.conf.urls import url urlpatterns = [ url(r'^users/$', UserList.as_view(), name="list_users"), url(r'^users/(?P<pk>\d+)/$', UserDetail.as_view(), name="detail_user"), url(r'^cities/(?P<pk>\d+)/$', CityDetail.as_view(), name="detail_city"), url(r'^cities/$', CityList.as_view(), name="list_cities"), url(r'^categories/$', CategoryList.as_view(), name="list_categories"), url(r'^categories/(?P<pk>\d+)/$', CategoryDetail.as_view(), name="detail_category"), url(r'^subcategories/$', SubCategoryList.as_view(), name="list_subcategories"), url(r'^subcategories/(?P<pk>\d+)/$', SubCategoryDetail.as_view(), name="subdetail_category"), url(r'^advertisements/$', ListCreateAdvertisement.as_view(), name="list_create_advertisement"), url(r'^advertisements/(?P<pk>\d+)/$', DetailUpdateDeleteAdvertisement.as_view(), name="detail_update_delete_advertisement") ]
Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') 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.contrib import admin from django.urls import path from api.views import AdDetail from api.views import FavouriteDetail from api.views import UserDetail from api.views import ProductFilterDetail from api.views import ProductSearch from api.views import CategoryDetail from django.conf.urls import url, include urlpatterns = [ path('admin/', admin.site.urls), url(r'^api/product/ad', AdDetail.as_view()), url(r'^api/favourite', FavouriteDetail.as_view()), url(r'^api/product/filter', ProductFilterDetail.as_view()), url(r'^api/product/find', ProductSearch.as_view()), url(r'^api/user', UserDetail.as_view()), url(r'^api/category', CategoryDetail.as_view()), ]