我使用 sqlite3
作为默认数据库,在本地构建了一个 Django 1.9 项目。我的应用程序名为 Download
,其中在 models.py
中定义了 DownloadedSongs
表:
models.py
from __future__ import unicode_literals
from django.db import models
class DownloadedSongs(models.Model):
song_name = models.CharField(max_length = 255)
song_artist = models.CharField(max_length = 255)
def __str__(self):
return self.song_name + ' - ' + self.song_artist
现在,为了将我的本地项目部署到Heroku,我在我的settings.py
文件底部添加了以下行:
import dj_database_url
DATABASES['default'] = dj_database_url.config()
我的应用程序有一个表单,其中包含几个文本字段。在提交该表单后,数据将插入DownloadedSongs
表中。现在,当我在Heroku上部署我的项目并尝试提交此表单时,我收到以下错误:
Exception Type: ProgrammingError at /download/
Exception Value: relation "Download_downloadedsongs" does not exist
LINE 1: INSERT INTO "Download_downloadedsongs" ("song_name", "song_a...
这是我的requirements.txt
文件的内容:
beautifulsoup4==4.4.1
cssselect==0.9.1
dj-database-url==0.4.1
dj-static==0.0.6
Django==1.9
django-toolbelt==0.0.1
gunicorn==19.6.0
lxml==3.6.0
psycopg2==2.6.1
requests==2.10.0
static3==0.7.0
另外,我也尝试运行了以下命令:
heroku run python manage.py makemigrations
heroku run python manage.py migrate
然而,问题仍然存在。这里似乎出了什么问题?
syndb
命令在 Django 1.9 中已被弃用。但我确保运行了makemigrations
命令。 - Manas Chaturvedi