zoukankan      html  css  js  c++  java
  • Django 中的urls 导入

    node2:/django/mysite/mysite#cat urls.py
    """mysite URL Configuration
    
    The `urlpatterns` list routes URLs to views. For more information please see:
        https://docs.djangoproject.com/en/1.11/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. 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 include,url
    from django.contrib import admin
    from blog import views as view
    urlpatterns =( 
    url(r'^admin/', admin.site.urls),
    url(r'^blog/$',view.archive),
    url(r'^articles/',include("news.urls"))
    )
    
    
    node2:/django/mysite/news#cat urls.py
    from django.conf.urls import url
    
    from . import views
    
    urlpatterns = [
        url(r'([0-9]{4})/', views.year_archive),
        #url(r'^articles/([0-9]{4})/$', views.year_archive),
        #url(r'^articles/([0-9]{4})/([0-9]{2})/$', views.month_archive),
        #url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', views.article_detail),
    ]
    
    http://192.168.137.3:8000/articles/9999/
    
    
    TemplateDoesNotExist at /articles/9999/
    
    news/year_archive.html
    
    Request Method: 	GET
    Request URL: 	http://192.168.137.3:8000/articles/9999/
    Django Version: 	1.11
    Exception Type: 	TemplateDoesNotExist
    Exception Value: 	
    
    news/year_archive.html
    
    Exception Location: 	/usr/local/python27/lib/python2.7/site-packages/django/template/loader.py in get_template, line 25
    Python Executable: 	/usr/local/python27/bin/python
    Python Version: 	2.7.3
    Python Path: 	
    
    ['/django/mysite',
     '/usr/local/python27/lib/python27.zip',
     '/usr/local/python27/lib/python2.7',
     '/usr/local/python27/lib/python2.7/plat-linux2',
     '/usr/local/python27/lib/python2.7/lib-tk',
     '/usr/local/python27/lib/python2.7/lib-old',
     '/usr/local/python27/lib/python2.7/lib-dynload',
     '/usr/local/python27/lib/python2.7/site-packages',
     '/usr/local/python27/lib/python2.7/site-packages/setuptools-33.1.1-py2.7.egg',
     '/usr/local/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg',
     '/usr/local/python27/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg']
    
    Server time: 	Sat, 18 Nov 2017 17:34:49 +0000

  • 相关阅读:
    尽量采用as操作符而不是旧式C风格做强制类型转换
    尽量使用条件属性(Conditional Attribute)而不是#if/#endif预处理
    C#跟踪和调试程序-Debug类使用
    C#使用ConditionalAttribute特性来实现代码调试
    微软认知服务:QnA Maker使用示例
    PHP使用微软认知服务Face API
    微软认知服务识别名人和地标
    基于apache httpclient 调用Face++ API
    认知服务调用如何使用图片的DataURL
    Microsoft Azure Storage Exployer使用指南
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349419.html
Copyright © 2011-2022 走看看