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

  • 相关阅读:
    Free DIY Tour_DP
    找出直系亲属_floyd
    Constructing Roads In JGShining's Kingdom_最长上升子序列
    买卖股票_线性dp
    Common Subsequence_公共子序列
    Doing Homework_状态压缩&&位运算
    猴子选大王
    卡片游戏
    Java 2
    Java 1
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349419.html
Copyright © 2011-2022 走看看