from django.conf.urls import url, include from Shop.settings import MEDIA_ROOT from django.views.static import serve from rest_framework.documentation import include_docs_urls from goods.views_base import GoodsListView as good1 from goods.views import GoodsListView as good2 from goods.generics_views import GoodsListView as good3 from goods.sets_views import GoodsListView as good4 from rest_framework.routers import DefaultRouter # from django.contrib import admin router = DefaultRouter() router.register(r'goods5', good4) goods_list = good4.as_view({'get': 'list', 'post': 'create'}) urlpatterns = [ # url(r'^admin/', admin.site.urls), url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), # 使图片正确显示 url(r'^api-auth/', include('rest_framework.urls')), # 商品列表 url(r'^goods1/$', good1.as_view(), name="goods-list1"), url(r'^goods2/$', good2.as_view(), name="goods-list2"), url(r'^goods3/$', good3.as_view(), name="goods-list3"), url(r'^goods4/$', goods_list, name="goods-list4"), url(r'^', include(router.urls)), url(r'^docs/', include_docs_urls(title='shop文档')), ]
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 url,include # from django.contrib import admin import xadmin from VueShop.settings import MEDIA_ROOT from django.views.static import serve from rest_framework.documentation import include_docs_urls from goods.views_base import GoodsListView urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^media/(?P<path>.*)$',serve,{"document_root":MEDIA_ROOT}), url(r'^api-auth/', include('rest_framework.urls')), url(r'goods/$',GoodsListView.as_view(),name="goods-list"), url(r'docs/',include_docs_urls(title="VueShop")) ]
base_name='shopcarts') #购物车URl router.register(r'orders', OrderViewset, base_name='orders') #订单相关url router.register(r'banners', BannerViewSet, base_name='banners') #轮播图url router.register(r'indexgoods', IndexCategoryViewSet, base_name='indexgoods') #首页商品系列数据url from django.views.decorators.cache import cache_page urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), # url(r'^goods/$',goods_list, name='goods_list'), url(r'^', include(router.urls)), url(r'^docs/', include_docs_urls(title='慕学生鲜')), url(r'^index/', TemplateView.as_view(template_name="index.html"), name="index"), # 富文本相关url url(r'^ueditor/', include('DjangoUeditor.urls')), #drf自带的token认证模式 url(r'^api-token-auth/', views.obtain_auth_token), #jwt的认证接口 url(r'^login/', obtain_jwt_token), url(r'^alipay/return/', Alipayview.as_view(), name='alipay'), url( r'^do/', cache_page(5)(GoodsListView.as_view()), ), ]
The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/topics/http/urls/ 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, include import xadmin from django.conf import settings from django.conf.urls.static import static from goods.views_base import GoodsListView from rest_framework.documentation import include_docs_urls from goods.views import GoodsListView urlpatterns = [ path('admin/', xadmin.site.urls), path('ueditor/', include('DjangoUeditor.urls')), path('api-auth/', include('rest_framework.urls')), # 商品列表页 path('goods/', GoodsListView.as_view(), name="goods-list"), path('docs/', include_docs_urls(title='mx')) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
url(r'^api/v1/', include(router.urls)), # router注册的APIh url(r'^index/', TemplateView.as_view(template_name="index.html"), name="index"), url(r'docs/', include_docs_urls(title="慕学生鲜")), # drf自带的token认证模式 url(r'^api-token-auth/', views.obtain_auth_token), # jwt的认证接口 url(r'^auth/login/$', obtain_jwt_token), url(r'^alipay/return/', AlipayView.as_view(), name="alipay"), ########################################################################### url(r'^goodsbase/$', GoodsListView.as_view()), url(r'^goodssimple/$', GoodsSimpleListview.as_view()), url(r'^simplegoodsset/$', goods_simple_list), # url(r'^detail/(?P<pk>\d+)/$',GoodsDetailViewSet.as_view({'get':'retrieve'})), # url(r'^detail/(?P<pk>\d+)/$',GoodsDetailViewSet.as_view()), url(r'^detail/(?P<pk>\d+)/$',GoodsDetailViewSet.detail), url(r'^login/weibo/$',WeiboLoginViewSet.login), # 设置appkey,以及下面的回调 url(r'^complete/weibo/$',WeiboLoginViewSet.get_access_token), # url(r'^complete/weibo/(?P<code>\w+)/$',WeiboLoginViewSet.get_access_token), # 第三方登录 social_login url('', include('social_django.urls', namespace='social')), # 性能分析工具
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, include from django.conf.urls import url from MxShop.settings import MEDIA_ROOT from django.views.static import serve import xadmin # 以下是测试用的 from goods.views_base import GoodsListView urlpatterns = [ # path('admin/', admin.site.urls), path(r'admin', xadmin.site.urls), url(r'^ueditor/', include('DjangoUeditor.urls')), url(r'^media/(?P<path>.*)/$', serve, {'document_root': MEDIA_ROOT}), # 图片路径 # 商品列表页 # path('goods/',include('goods.urls')), path('goods/',GoodsListView.as_view(),name='goods_list'), ]
from rest_framework.documentation import include_docs_urls from goods.views_base import GoodsListView as good1 from goods.views import GoodsListView as good2 from goods.generics_views import GoodsListView as good3 from goods.sets_views import GoodsListView as good4 from rest_framework.routers import DefaultRouter # from django.contrib import admin router=DefaultRouter() router.register(r'goods5',good4) goods_list = good4.as_view({ 'get': 'list', 'post': 'create' }) urlpatterns = [ # url(r'^admin/', admin.site.urls), url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), # 使图片正确显示 url(r'^api-auth/', include('rest_framework.urls')), # 商品列表 url(r'^goods1/$', good1.as_view(), name="goods-list1"), url(r'^goods2/$', good2.as_view(), name="goods-list2"), url(r'^goods3/$', good3.as_view(), name="goods-list3"), url(r'^goods4/$', goods_list, name="goods-list4"), url(r'^', include(router.urls)), url(r'^docs/', include_docs_urls(title='shop文档')), ]