zoukankan      html  css  js  c++  java
  • from django.db.models.fields import FieldDoesNotExist

    from django.db.models.fields import FieldDoesNotExist

    错误代码如下:
    Traceback (most recent call last):
    File "../../manage.py", line 15, in
    execute_from_command_line(sys.argv)
    File "C:virtualenvslfobjlibsite-packagesdjangocoremanagement_init_.py", line 401, in execute_from_command_line
    utility.execute()
    File "C:virtualenvslfobjlibsite-packagesdjangocoremanagement_init_.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    File "C:virtualenvslfobjlibsite-packagesdjangocoremanagementase.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
    File "C:virtualenvslfobjlibsite-packagesdjangocoremanagementase.py", line 368, in execute
    self.check()
    File "C:virtualenvslfobjlibsite-packagesdjangocoremanagementase.py", line 396, in check
    databases=databases,
    File "C:virtualenvslfobjlibsite-packagesdjangocorechecks egistry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
    File "C:virtualenvslfobjlibsite-packagesdjangocorechecksurls.py", line 13, in check_url_config
    return check_resolver(resolver)
    File "C:virtualenvslfobjlibsite-packagesdjangocorechecksurls.py", line 23, in check_resolver
    return check_method()
    File "C:virtualenvslfobjlibsite-packagesdjangourls esolvers.py", line 408, in check
    for pattern in self.url_patterns:
    File "C:virtualenvslfobjlibsite-packagesdjangoutilsfunctional.py", line 48, in get
    res = instance.dict[self.name] = self.func(instance)
    File "C:virtualenvslfobjlibsite-packagesdjangourls esolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    File "C:virtualenvslfobjlibsite-packagesdjangoutilsfunctional.py", line 48, in get
    res = instance.dict[self.name] = self.func(instance)
    File "C:virtualenvslfobjlibsite-packagesdjangourls esolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
    File "d:python36libimportlib_init_.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File "", line 994, in _gcd_import
    File "", line 971, in _find_and_load
    File "", line 955, in _find_and_load_unlocked
    File "", line 665, in _load_unlocked
    File "", line 678, in exec_module
    File "", line 219, in call_with_frames_removed
    File "C:UsersmaynDesktopluffyluffyapiluffyapiurls.py", line 22, in
    path('home/', include('home.urls')),
    File "C:virtualenvslfobjlibsite-packagesdjangourlsconf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
    File "d:python36libimportlib_init
    .py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File "", line 994, in _gcd_import
    File "", line 971, in _find_and_load
    File "", line 955, in _find_and_load_unlocked
    File "", line 665, in _load_unlocked
    File "", line 678, in exec_module
    File "", line 219, in _call_with_frames_removed
    File "C:UsersmaynDesktopluffyluffyapiluffyapiappshomeurls.py", line 20, in
    from . import views
    File "C:UsersmaynDesktopluffyluffyapiluffyapiappshomeviews.py", line 2, in
    from rest_framework.generics import ListAPIView
    File "C:virtualenvslfobjlibsite-packages est_frameworkgenerics.py", line 9, in
    from rest_framework import mixins, views
    File "C:virtualenvslfobjlibsite-packages est_frameworkmixins.py", line 8, in
    from rest_framework.response import Response
    File "C:virtualenvslfobjlibsite-packages est_framework esponse.py", line 11, in
    from rest_framework.serializers import Serializer
    File "C:virtualenvslfobjlibsite-packages est_frameworkserializers.py", line 24, in
    from django.db.models.fields import FieldDoesNotExist
    ImportError: cannot import name 'FieldDoesNotExist'

    问题原因:
    一开始装的是django2.0.7,然后安装pip install django-cors-headers,未指定版本,结果安装了最新版3.5,且自动把django升到了3.5版本,然而无论是启动项目,还是迁移数据库,都报错.
    解决办法:
    把django3.5卸了,装回2.0.7,重新安装django-cors-headers的3.1版本.然后就好了.
    总结:
    版本适配问题.

  • 相关阅读:
    【原】Go语言及Web框架Beego环境无脑搭建
    Treap学习笔记
    读书笔记--Head First PMP目录
    Linux操作系统常用命令合集——第四篇-文件系统权限操作(5个命令)
    Linux操作系统常用命令合集——第三篇-系统管理操作(25个命令)
    Linux操作系统常用命令合集——第二篇- 用户和组操作(15个命令)
    路由器与交换机配置——配置文件和系统映像备份与恢复
    路由器配置——密码重置
    交换机配置——端口安全
    路由器与交换机配置——交换机默认网关(实现跨网段telnet)
  • 原文地址:https://www.cnblogs.com/hellozizi/p/13865205.html
Copyright © 2011-2022 走看看