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.views.static import serve # from django.conf import settings # from django.conf.urls.static import static import xadmin from product.views import IndexView from user.views import LoginView, RegisterView urlpatterns = [ # path('admin/', admin.site.urls), path('xadmin/', xadmin.site.urls), path('', IndexView.as_view(), name="index_1"), # 首页 path('login/', LoginView.as_view(), name="login_1"), # 登录页面 path('register/', RegisterView.as_view(), name="register_1"), # 注册页面 path("user/", include("user.urls")), # 用户相关视图板块 path("product/", include("product.urls")), # 产品/商品相关视图板块 path("cart/", include("cart.urls")), # 购物车操作相关视图 path("order/", include("order.urls")), # 订单相关处理视图 path("pay/", include("pay.urls")), # 支付相关处理 # 静态文件处理(主要是之前上传的文件等静态资源)========这个bug 应该说这个静态地址 研究了半天 # path('media/<path:path>/', serve, {"document_root": settings.MEDIA_ROOT}), # path('static/<path:path>/', serve, {"document_root": settings.STATIC_ROOT}), ] # + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
"""app URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.8/topics/http/urls/ 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. Add an import: from blog import urls as blog_urls 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import include, url from django.contrib import admin from product.views import IndexView, RegExpView, OrmView, QuestionsView, SqlView, DiscountView, GitView urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^$', IndexView.as_view(), name='index'), url(r'^reg-exp/', RegExpView.as_view(), name='reg_exp'), url(r'^orm/', OrmView.as_view(), name='orm'), url(r'^questions/', QuestionsView.as_view(), name='questions'), url(r'^sql/', SqlView.as_view(), name='sql'), url(r'^discount/', DiscountView.as_view(), name='discount'), url(r'^git/', GitView.as_view(), name='git'), ]
2. Import the include() function: from django.conf.urls import url, include 3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import url, include from django.views.generic import TemplateView import xadmin from django.views.static import serve #处理静态文件 from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView from product.views import ClassificationView, IndexView from ImitationTmall.settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^$', IndexView.as_view(), name="index"), url(r'^register/$', RegisterView.as_view(), name="register"), url(r'^login/$', LoginView.as_view(), name="login"), url(r'^captcha/', include('captcha.urls')), url(r'^active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name="user_active"), url(r'^reset/(?P<reset_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^modify_pwd/$', ModifyPwdView.as_view, name="modify_pwd"), url(r'^forget/$', ForgetPwdView.as_view, name="forget_pwd"), # url(r'^classification/$', TemplateView.as_view(template_name="classification.html"), name="classification"), url(r'^base/$', TemplateView.as_view(template_name="base.html"), name="base"),
from django.contrib import admin from ozna.views import MainView from contact.views import ContactView from contact.views import ThanksView from news.views import NewsView from about.views import AboutView from product.views import ProductView from product.views import KtpView from product.views import productdetail, ktpview, IndexView from gear.views import GearView from contact.views import contact, rssview urlpatterns = [ url(r'^pkf/', admin.site.urls), url(r'^$', IndexView.as_view(), name="main"), url(r'^contacts/$', ContactView.as_view(), name="contacts"), url(r'^news/$', NewsView.as_view(), name="news"), url(r'^about/$', AboutView.as_view(), name="about"), url(r'^product/$', ProductView.as_view(), name="product"), url(r'^product/(?P<service_id>\d+)/$', ktpview, name="ktp"), url(r'^gear/$', GearView.as_view(), name="gear"), url(r'^form/$', contact, name="form"), url(r'^thanks/$', ThanksView.as_view(), name="thanks"), url(r'^product/(?P<alias>[^/]+)/$', productdetail, name='productdetail'), url(r'^rss/$', MainView, name='rss'), ]
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.conf import settings from django.conf.urls.static import static from django.urls import path from product import views from product.views import ProductUpdateView, ProductDeleteView, ManagerProductsView, IndexView urlpatterns = [ path('manager/products', ManagerProductsView.as_view(), name='manager-products'), path('index/', IndexView.as_view(), name='index'), # path('product/', ProductListView.as_view(), name='add_product'), path('product/<int:pk>/update/', ProductUpdateView.as_view(), name='product-update'), path('product/<int:pk>/delete/', ProductDeleteView.as_view(), name='product-delete'), ]
3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import include, url from django.contrib import admin from django.views.static import serve import xadmin from .settings import MEDIA_ROOT from product.views import IndexView from account.views import ModifyView, ResetView, ForgetPwdView, ActiveUserView, RegisterView, LogoutView, LoginView urlpatterns = [ url(r'^$', IndexView.as_view(), name='index'), url(r'^login/$', LoginView.as_view(), name='login'), url(r'^logout/$', LogoutView.as_view(), name='logout'), url(r'^register/$', RegisterView.as_view(), name='register'), url(r'^active/(?P<pk>.*)/$', ActiveUserView.as_view(), name='active'), url(r'^forget/$', ForgetPwdView.as_view(), name='forget'), url(r'^reset/(?P<pk>.*)/$', ResetView.as_view(), name='reset'), url(r'^modify/$', ModifyView.as_view(), name='modify'), url(r'^product/', include('product.urls', namespace='product')), url(r'^user/', include('account.urls', namespace='user')), url(r'^admin/', xadmin.site.urls),
path('order_entity/v1/', include('order.api.urls', namespace='order_api')), path('docs/', include_docs_urls(title='ShopSite Apis')), ])), # path('api-auth', include('rest_framework.urls', namespace='rest_framework')) ] translate_urlpatterns = i18n_patterns( # path('view/', include([ path(_('user/'), include('user.urls', namespace='user_view')), path(_('item/'), include('product.urls', namespace='product_view')), path(_('cart/'), include('cart.urls', namespace='cart_view')), path(_('order/'), include('order.urls', namespace='order_view')), path(_('store/'), include('shop.urls', namespace='shop_view')), path(_('payment/'), include('payment.urls', namespace='payment_view')), path('rosetta/', include('rosetta.urls')), path('', IndexView.as_view(), name='index_view'), # ])), ) urlpatterns = translate_urlpatterns + [ # View URL List # Admin page url path('admin/', admin.site.urls), path('', include(api_patterns)), ] if settings.DEBUG: urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)