• 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

  • 相关阅读:
    C#限速下载网络文件
    MVC与WebApi中的异常统一处理
    Javascript闭包(Closure)
    HTML转义字符 Unicode和CSS伪类介绍
    .NET通用工具——正则表达式
    C#的格式化(进制转换|位运算)
    javascript中的类型转换(进制转换|位运算)
    MVC中的七层架构
    Excel中的常用功能
    jQuery基础
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349419.html
Copyright © 2020-2023  润新知