我创建了两个自定义模型:Picture
和Album
我已将它们迁移到数据库中,并且数据库中都存在这两个表
在管理员中,我想创建一个自定义管理面板,所以在 admin.py 我有
#admin.py
from django.contrib import admin
from testrest.models import Picture, Album
class AlbumAdmin(admin.ModelAdmin):
fields = ['album_name']
admin.site.register(Album, AlbumAdmin)
我的 models.py 文件:
#models.py
from django.db import models
class Album(models.Model):
album_name = models.CharField(max_length=30)
def __str__(self):
return self.album_name
class Picture(models.Model):
file_name = models.CharField(max_length=30)
google_hash = models.CharField(max_length=100)
date_added = models.DateField()
albums = models.ManyToManyField(Album)
def __str__(self):
return self.file_name
class Meta:
ordering = ('date_added',)
我得到的错误:
ProgrammingError at /admin/testrest/album/
relation "testrest_album" does not exist
LINE 1: SELECT COUNT(*) FROM "testrest_album"
^
Request Method: GET
Request URL: http://localhost:5000/admin/testrest/album/
Django Version: 1.7.7
Exception Type: ProgrammingError
Exception Value:
relation "testrest_album" does not exist
LINE 1: SELECT COUNT(*) FROM "testrest_album"
^
Exception Location: /home/yonk/projects/apple/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py in execute, line 65
Python Executable: /home/yonk/projects/apple/venv/bin/python
Python Version: 2.7.6
Python Path:
['/home/yonk/projects/apple',
'/home/yonk/projects/apple/venv/bin',
'/home/yonk/projects/apple/venv/lib/python2.7',
'/home/yonk/projects/apple/venv/lib/python2.7/plat-x86_64-linux-gnu',
'/home/yonk/projects/apple/venv/lib/python2.7/lib-tk',
'/home/yonk/projects/apple/venv/lib/python2.7/lib-old',
'/home/yonk/projects/apple/venv/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/yonk/projects/apple/venv/local/lib/python2.7/site-packages']
Server time: Thu, 26 Mar 2015 22:24:13 +0000
答案 0 :(得分:0)
解决了问题。 它以某种方式连接到一个不同的数据库,有一个Gunicorn的幽灵会话在后台运行,在杀死进程并重启Gunicorn后问题得到解决