Django Admin无法找到存在的数据:“也许已删除?”

时间:2019-04-23 10:15:01

标签: django python-3.x

我有一个与此问题类似的问题:

Tablename with ID "Some_ID" doesn't exist. Perhaps it was deleted? Django Sqlite

该问题仅在以下一种特定模型上出现:

class Kinterms(models.Model):
    kin_category = models.TextField(blank=True, null=True)  # This field type is a guess.
    parameter = models.TextField(blank=True, null=True)  # This field type is a guess.
    term = models.TextField(blank=True, null=True)  # This field type is a guess.
    ipa_term = models.TextField(blank=True, null=True)  # This field type is a guess.
    alternative_address = models.TextField(blank=True, null=True)  # This field type is a guess.
    comment = models.TextField(blank=True, null=True)  # This field type is a guess.
    sourceid = models.TextField(db_column='sourceID', blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    coder = models.TextField(blank=True, null=True)  # This field type is a guess.
    speaking = models.TextField(blank=True, null=True)  # This field type is a guess.
    kinbank_id = models.TextField(blank=True, null=True)  # This field type is a guess.
    glottocode = models.TextField(blank=True, null=True)  # This field type is a guess.
    row_id = models.TextField(unique=True, blank=True, primary_key = True)  # This field type is a guess.

    class Meta:
        managed = False
        db_table = 'kinterms'

    def __str__(self):
        return self.row_id

哪个在管理文件中显示为

from django.contrib import admin

from .models import Kinterms, Metadata, Sources, Coder
# Register your models here.
admin.site.register(Kinterms)

与链接的问题一样,每当我登录到管理站点并单击Kinterms模型的行时,我都会回到管理主页,并且标语“ ID为“ XXXX”的Kinterms不存在。也许它被删除了?”

重新创建数据库不能解决该问题。我可以使用数据库查看器在数据库中手动找到值。

我为所有其他工作正常的表设置了完全相同的设置。我可以注意到的唯一区别是,该表使用数字作为主键,而其他键则是字符。尽管它们都是TextField,所以我认为这无关紧要。

我不确定要查找什么,因为没有明显的错误发生。因此,请让我知道是否还有其他有用的信息。

0 个答案:

没有答案