Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.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 为什么我会得到错误:OperationalError at/table/没有这样的表:table\u book_Python_Django - Fatal编程技术网

Python 为什么我会得到错误:OperationalError at/table/没有这样的表:table\u book

Python 为什么我会得到错误:OperationalError at/table/没有这样的表:table\u book,python,django,Python,Django,每当我运行程序时,都会出现以下错误: OperationalError at /table/ no such table: table_book 它说在我的模板文件的第7行有一个错误 这是我的template.html: <table> <tr> <th>author</th> <th>title</th> <th>publication year</th> </tr> {

每当我运行程序时,都会出现以下错误:

OperationalError at /table/ 
no such table: table_book
它说在我的模板文件的第7行有一个错误

这是我的template.html:

<table>
<tr>
  <th>author</th>
  <th>title</th>
  <th>publication year</th>
</tr>
{% for b in obj %}
<tr>
  <td>{{ b.author }}</td>
  <td>{{ b.title }}</td>
  <td>{{ b.publication_year }}</td>
</tr>
{% endfor %}
</table>
这是我的models.py:

from django.db import models

class Book(models.Model):
    author = models.CharField(max_length = 20)
    title = models.CharField(max_length = 40)
    publication_year = models.IntegerField()
这是我的URL.py:

from django.conf.urls import url
from . import views

urlpatterns = [
    # /table/
    url(r'^$', views.display, name='display'),
]

谁能告诉我怎么了吗?

数据库表手册不见了。您运行makemigrations和migrate了吗?

哦,我忘了迁移。。。我现在就去做。
from django.conf.urls import url
from . import views

urlpatterns = [
    # /table/
    url(r'^$', views.display, name='display'),
]