资讯专栏INFORMATION COLUMN

viewmustbeacallable or a list/tuple in the caseof

cocopeak / 1288人阅读

摘要:修改添加上面的规则首页栏目文章详情启动服务器解决方案见将写成解决方案可以替换为你新建的应用名称是在你创建的应用下的写法改为参考的写法

"""minicms 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 url
from django.contrib import admin
#
from django.conf import settings
 
#
from django.conf.urls import include, url
from DjangoUeditor import urls as DjangoUeditor_urls
from news.views import index
from news.views import column_detail
from news.views import article_detail
urlpatterns = [
# 修改 minicms/urls.py 添加上面的规则:
# 首页 index   栏目 column    文章详情   article
    #url(r"^blog/", include("blog.urls"))
    url(r"^$", index),
    #url(r"^column/(?P[^/]+)/$", "news.views.column_detail", name="column"),
    #url(r"^news/(?P[^/]+)/$", "news.views.article_detail", name="article"),
# 
    #url(r"^ueditor/", include("DjangoUeditor.urls" )),
    #url(r"^admin/", admin.site.urls),

    #url(r"^$", "news.views.index", name="index"),
    url(r"^column/(?P[^/]+)/$", column_detail),
    url(r"^news/(?P[^/]+)/$", article_detail),
 
    url(r"^admin/", include(admin.site.urls)),
]

if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(

        settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
启动服务器:python manage.py runserver
System check identified no issues (0 silenced).
July 24, 2017 - 20:50:33
Django version 1.11.3, using settings "minicms.settings"
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.


解决方案1:
见https://stackoverflow.com/que...
将url(r"^website/$","website.views.first_page"),写成url(r"^website/$", website.views.first_page),
解决方案2:
from news import views

news可以替换为你新建的app应用名称,vies.py是在你创建的app应用下的
url(r"^$", index),
    #url(r"^column/(?P[^/]+)/$", news.views.column_detail", name="column"),
    #url(r"^news/(?P[^/]+)/$", news.views.article_detail", name="article"),
 

写法改为:

url(r"^$", views.index, name="index"),
    url(r"^column/(?P[^/]+)/$", views.column_detail, name="column"),
    url(r"^news/(?P[^/]+)/$", views.article_detail, name="article"),

【参考】http://blog.csdn.net/godlikeb...
的写法

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/40649.html

相关文章

  • python learn 02 senior more

    摘要:如果使用的是前缀,多余的参数则会被认为是一个字典的键值对。表达式语句被用来创建新的函数对象,并且在运行时返回它们。函数函数用来取得对象的规范字符串表示。反引号也称转换符可以完成相同的功能。基本上,函数和反引号用来获取对象的可打印的表示形式。 Content List 1.Datastruct 1.1 List 1.2 Tuple 1.3 Dict 1.4 Seq 2.I/O...

    nanchen2251 评论0 收藏0
  • 流畅的python

    摘要:流畅的中有很多奇技淫巧,整本书都在强调如何最大限度地利用标准库。常见的扁平序列包括,,等。数组支持所有跟可变序列有关的操作,包括和。和用于指定列表的区间,默认是使用整个列表。但是元组的赋值不被允许,当异发生时 流畅的python中有很多奇技淫巧,整本书都在强调如何最大限度地利用Python 标准库。介绍了很多python的不常用的数据类型、操作、库等,对于入门python后想要提升对p...

    Alan 评论0 收藏0
  • Pythonista 容易忽略的python编程方式

    摘要:字典是内置的数据结构,在写程序时会经常用到。这里介绍一下它的方法和方法。在获取中的数据时,我们一般使用的方式,但是如果不存在的时候会抛出。 Python 之禅 The Zen of Python, by Tim Peters Beautiful is better than ugly. 优美胜于丑陋(Python以编写优美的代码为目标) Explicit is be...

    wendux 评论0 收藏0
  • python中的listtuple,set和dict(参考python文档)

    摘要:声明一个很简单,只需尽量不要将变量名起为关键字。有如下基本方法在的末尾添加一个元素,并且返回将另一个的对象添加到尾部,返回值为。返回值为删掉的元素。为一个表达式,传入当前元素,返回时依据德关键字。 1.list 声明一个list很简单,只需list1=[](尽量不要将变量名起为关键字list)。list有如下基本方法: (1)append(x) 在list的末尾添加一个元素x,并且返回...

    NervosNetwork 评论0 收藏0
  • 不可不知的python模块--collections

    摘要:原生的也可以从头部添加和取出对象就像这样但是值得注意的是,对象的这两种用法的时间复杂度是,也就是说随着元素数量的增加耗时呈线性上升。 基本介绍 Python拥有一些内置的数据类型,比如str, int, list, tuple, dict等, collections模块在这些内置数据类型的基础上,提供了几个额外的数据类型: namedtuple(): 生成可以使用名字来访问元素内容的...

    韩冰 评论0 收藏0

发表评论

0条评论

cocopeak

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<