Django之创建引擎索引报错及解决详解

yipeiwu_com6年前Python基础

学习Django框架时,创建一个引擎及索引时报错,具体报错如下:

执行命令:

python3 manage.py rebuild_index

报如下错误:

......(前面一堆报错)
File "/home/python/Django/test6/test6/urls.py", line 20, in <module>
  url(r'^admin/', include(admin.site.urls)),
 File "/home/python/.virtualenvs/py_django/lib/python3.6/site-packages/django/urls/conf.py", line 27, in include
  'provide the namespace argument to include() instead.' % len(arg)
django.core.exceptions.ImproperlyConfigured: Passing a 3-tuple to include() is not supported. Pass a 2-tuple containing the list of patterns and app_name, and provide the namespace argument to include() instead.

可以看到以上报错中第2行代码:

url(r'^admin/', include(admin.site.urls)),

网上查询后,将项目路径下的urls.py文件的这一行代码改为:

url(r'^admin/', admin.site.urls),

再次执行python3 manage.py rebuild_index,不再报错.

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python:动态路由的Flask程序代码

python:动态路由的Flask程序代码

如下所示: # Copyright (c)2018, 东北大学软件学院学生 # All rightsreserved # 文件名称:a.py # 作 者:孔云...

使用Python读取二进制文件的实例讲解

使用Python读取二进制文件的实例讲解

目标:目标文件为一个float32型存储的二进制文件,按列优先方式存储。本文使用Python读取该二进制文件并使用matplotlib.pyplot相关工具画出图像 工具:Python3...

使用Python对Excel进行读写操作

学习Python的过程中,我们会遇到Excel的读写问题。这时,我们可以使用xlwt模块将数据写入Excel表格中,使用xlrd模块从Excel中读取数据。下面我们介绍如何实现使用Pyt...

python取数作为临时极大值(极小值)的方法

编程中有时候需要一个初始极大值(或极小值)作为temp,当然可以自定义设置为10000(whatever),不过python中有一个值可以代替之: 在python2.7中可以用这个(不...

python合并文本文件示例

python实现两个文本合并 employee文件中记录了工号和姓名复制代码 代码如下:cat employee.txt:100 Jason Smith200 John Doe300 S...