创建了一个Django项目,且包含一个admin的app,但是在启动Django的是时候抛出了以下异常:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000180A3C34400>
Traceback (most recent call last):
File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
autoreload.raise_last_exception()
File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "C:\Python37\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Python37\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Python37\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python37\lib\site-packages\django\apps\registry.py", line 89, in populate
"duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin
最后提示是:
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin
说:应用程序标签不是唯一的,重复的: admin
查看配置文件:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'admin.apps.AdminConfig',
]
第一个和最后一个貌似有点重复,尝试注释掉最后一个
会发现没有数据库:
E:\Project\library>python manage.py migrate
Traceback (most recent call last):
File "C:\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 26, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 338, in execute
django.setup()
File "C:\Python37\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python37\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Python37\lib\site-packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "C:\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Python37\lib\site-packages\django\contrib\auth\models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Python37\lib\site-packages\django\contrib\auth\base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "C:\Python37\lib\site-packages\django\db\models\base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Python37\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Python37\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Python37\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python37\lib\site-packages\django\db\utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python37\lib\site-packages\django\db\utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 30, in <module>
'Did you install mysqlclient or MySQL-python?' % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'.
Did you install mysqlclient or MySQL-python?
但是数据库的配置已经配置好了:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'library',
'HOST': '127.0.0.1',
'PORT': 3306,
'USER': 'root',
'PASSWORD': '########',
}
}
最后发现是应用名称和Django内置admin.py冲突了修改文件名就ok了
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin的更多相关文章
-
Django django.core.exceptions.ImproperlyConfigured: WSGI application &#39;myblog.wsgi.application&#39; could not be loaded; Error importing module.报错
报错内容 django.core.exceptions.ImproperlyConfigured: WSGI application 'myblog.wsgi.application' could n ...
-
django报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
django 迁移数据库报错 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you ins ...
-
解决:django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not 的方法
错误类型: 该错误是在在创建Django工程时出现遇到的错误 完整报错信息:(博文标题输入长度有限制) django.core.exceptions.ImproperlyConfigured: Req ...
-
python基于Django框架编译报错“django.core.exceptions.ImproperlyConfigured”的解决办法?
下面是我具体遇到的问题和解决方法: 错误详细信息: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_IND ...
-
pythoncharm 中解决启动server时出现 “django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured”的错误
背景介绍 最近,尝试着用pythoncharm 这个All-star IDE来搞一搞Django,于是乎,下载专业版,PJ等等一系列操作之后,终于得偿所愿.可以开工了. 错误 在园子里找了一篇初学者的 ...
-
关于Django报错django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configure
报错代码:django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but se ...
-
【Django】django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
最近学习Django的过程中,在cmd打算使用python manage.py shell来测试数据的时候,当我一导入自己写的model类,就发现报了这个错误django.core.exception ...
-
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call
Error info: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, ...
-
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)
在python的开发中,遇到了这个错误: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TA ...
随机推荐
-
Linux信号(signal) 机制分析
Linux信号(signal) 机制分析 [摘要]本文分析了Linux内核对于信号的实现机制和应用层的相关处理.首先介绍了软中断信号的本质及信号的两种不同分类方法尤其是不可靠信号的原理.接着分析了内核 ...
-
[转] shell字符串操作方法,以及实例
每一种语言都有他独自的字符串操作方法,shell也一样,下面以以例子的方式,简单介绍常用方法. 1,取得字符串长度 string=abc12342341 //等号二边不要有空格 echo ${#str ...
-
Android之线程终止
Hanlder是线程与Activity通信的桥梁,利用handler接收到任务线程,放到任务队列里面派对执行. 1.初始化的时候,定义启动的线程为一个守护线程,这样当主线程消亡掉的时候,其他线程也会被 ...
-
web字体格式转换
@font-face { font-family: 'emotion'; src: url('emotion.eot'); /* IE9*/ src: url('emotion.eot?#iefix' ...
-
[LeetCode] Unique Paths 2
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
-
web中纯java获取配置文件中的数据
/*********获取配置文件,但配置文件中的值改变,不会随着值的改变也获取的参数值改变**********/ /** * 原因是因为,类装载,装载完后,不会再去装载了 * */// I ...
-
Ubuntu下安装Flask虚拟环境及使用
一.关于Flask介绍 诞生时间:Flask诞生于2010年,是Armin ronacher(人名)用 Python 语言基于 Werkzeug工具箱编写的轻量级Web开发框架. Flask框架包含两 ...
-
HDU1199 动态线段树 // 离散化
附动态线段树AC代码 http://acm.hdu.edu.cn/showproblem.php?pid=1199 因为昨天做了一道动态线段树的缘故,今天遇到了这题没有限制范围的题就自然而然想到了动态 ...
-
codeblocks技巧收集
Ctrl+Shift+C 注释代码块 Ctrl+Shift+X 取消注释
-
HTML5 Canvas ( 绘制一轮弯月, 星空中的弯月 )
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...