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'),
]