Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 操作错误:没有此类列,但列不';我哪儿也不存在_Python_Django - Fatal编程技术网

Python 操作错误:没有此类列,但列不';我哪儿也不存在

Python 操作错误:没有此类列,但列不';我哪儿也不存在,python,django,Python,Django,我正在建立一个Django网站,我是一个相对的初学者。 然而,这个错误让我困惑,所以请让我知道可能发生了什么 我犯了一个错误 django.db.utils.OperationalError:没有这样的列:metadata.id 但是在我的代码中没有metadata.id,也没有我正在使用的数据库。所以我真的很困惑这是从哪里来的 想必我已经修补了一些不该修补的地方 我的问题是,这条消息的开头是否给出了我应该在哪里查找错误的任何指示 我也有这个信息 在template…/kinbank2/temp

我正在建立一个Django网站,我是一个相对的初学者。 然而,这个错误让我困惑,所以请让我知道可能发生了什么

我犯了一个错误

django.db.utils.OperationalError:没有这样的列:metadata.id

但是在我的代码中没有metadata.id,也没有我正在使用的数据库。所以我真的很困惑这是从哪里来的

想必我已经修补了一些不该修补的地方

我的问题是,这条消息的开头是否给出了我应该在哪里查找错误的任何指示

我也有这个信息

在template…/kinbank2/templates/base.html中,第0行出现错误

这使得很难找到一行或文件来查看

谢谢

萨姆

错误回溯

    Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/language/

Django Version: 2.0.4
Python Version: 3.5.2
Installed Applications:
['home.apps.HomeConfig',
 'django_tables2',
 'language.apps.LanguageViewConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']


Template error:
In template /Users/sp16194/Desktop/Projects_Git/kinbank2/kinbank2/templates/base.html, error at line 0
   no such column: metadata.id
   1 : <!DOCTYPE html>
   2 : <html>
   3 : <head>
   4 :     <title>kinbank</title>
   5 : <!--      <link rel="stylesheet" href="styles.css"> -->
   6 :     {% block head %}{% endblock %}
   7 : </head>
   8 : <body>
   9 :  <div>
   10 :        <div class="page-width"> 


Traceback:

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
  85.                 return self.cursor.execute(sql, params)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py" in execute
  303.         return Database.Cursor.execute(self, query, params)

The above exception (no such column: metadata.id) was the direct cause of the following exception:

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/sp16194/Desktop/Projects_Git/kinbank2/language/views.py" in index
  19.   return render(request, 'language/index.html', context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/shortcuts.py" in render
  36.     content = loader.render_to_string(template_name, context, request, using=using)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/loader.py" in render_to_string
  62.     return template.render(context, request)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in render
  175.                     return self._render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in _render
  167.         return self.nodelist.render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in render
  943.                 bit = node.render_annotated(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  910.             return self.render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/loader_tags.py" in render
  155.             return compiled_parent._render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in _render
  167.         return self.nodelist.render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in render
  943.                 bit = node.render_annotated(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  910.             return self.render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/loader_tags.py" in render
  67.                 result = block.nodelist.render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in render
  943.                 bit = node.render_annotated(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  910.             return self.render(context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/template/defaulttags.py" in render
  313.             if match:

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/models/query.py" in __bool__
  276.         self._fetch_all()

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/models/query.py" in _fetch_all
  1179.             self._result_cache = list(self._iterable_class(self))

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/models/query.py" in __iter__
  53.         results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1067.             cursor.execute(sql, params)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  100.             return super().execute(sql, params)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  68.         return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
  77.         return executor(sql, params, many, context)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
  85.                 return self.cursor.execute(sql, params)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/utils.py" in __exit__
  89.                 raise dj_exc_value.with_traceback(traceback) from exc_value

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
  85.                 return self.cursor.execute(sql, params)

File "/Users/sp16194/anaconda/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py" in execute
  303.         return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /language/
Exception Value: no such column: metadata.id

它似乎添加了一个我没有的id列?我应该做些什么来阻止这一切

索引19中的文件“/Users/sp16194/Desktop/Projects\u Git/kinbank2/language/views.py”。返回render(请求'language/index.html',context)将帮助您解决此问题。如果在某个地方调用了metadata.id,请检查在第19行调用渲染的视图中调用的内容。可能是此视图使用的表单的表单字段Hi Roy,谢谢-这帮助我发现模型有问题,但我仍然没有名为metadata.id的列。如果我在所有文件中搜索这个,我不会得到任何结果,我很确定我从未使用过这样的专栏。您知道我是否可以重置某些内容吗?可能还有迁移问题,您是否在我的迁移之后运行makemigrations?很遗憾,是的。我想知道是否有某种临时文件可能包含此内容,我可以删除或重新创建。我会继续找的
id
字段由django自动添加到您的模型中作为主键,这并没有什么问题。如果您确定已经为该应用程序运行了
migrate
命令,并且没有此模型的任何重要数据。您是否可以尝试使用
python manage.py迁移语言zero
python manage.py迁移语言
再次重置和迁移。记住,这将删除索引19中数据库文件“/Users/sp16194/Desktop/Projects\u Git/kinbank2/language/views.py”中语言应用程序的所有数据。返回render(请求'language/index.html',context)将帮助您解决此问题。如果在某个地方调用了metadata.id,请检查在第19行调用渲染的视图中调用的内容。可能是此视图使用的表单的表单字段Hi Roy,谢谢-这帮助我发现模型有问题,但我仍然没有名为metadata.id的列。如果我在所有文件中搜索这个,我不会得到任何结果,我很确定我从未使用过这样的专栏。您知道我是否可以重置某些内容吗?可能还有迁移问题,您是否在我的迁移之后运行makemigrations?很遗憾,是的。我想知道是否有某种临时文件可能包含此内容,我可以删除或重新创建。我会继续找的
id
字段由django自动添加到您的模型中作为主键,这并没有什么问题。如果您确定已经为该应用程序运行了
migrate
命令,并且没有此模型的任何重要数据。您是否可以尝试使用
python manage.py迁移语言zero
python manage.py迁移语言
再次重置和迁移。请记住,这将删除数据库中语言应用程序的所有数据。
migrations.CreateModel(
    name='Metadata',
    fields=[
        ('id', models.AutoField(auto_created=True,primary_key=True, serialize=False, verbose_name='ID')),
        ('kinbank_id', models.TextField(blank=True, null=True, unique=True)),
        ('preferred_name', models.TextField(blank=True, db_column='Preferred_name', null=True)),
        ('language_family', models.TextField(blank=True, db_column='Language_Family', null=True)),
        ('latitude', models.TextField(blank=True, db_column='Latitude', null=True)),
        ('longitude', models.TextField(blank=True, db_column='Longitude', null=True)),
        ('glottolog_id', models.TextField(blank=True, db_column='Glottolog_id', null=True)),
        ('dplace_id', models.TextField(blank=True, db_column='DPLACE_id', null=True)),
        ('iso_code', models.TextField(blank=True, db_column='ISO_code', null=True)),
        ('status', models.TextField(blank=True, db_column='Status', null=True)),
        ('notes', models.TextField(blank=True, db_column='Notes', null=True)),
        ('url', models.TextField(blank=True, null=True)),
    ],
    options={
        'managed': False,
        'db_table': 'metadata',
    },