ID为"Some_ID"的表名;不存在.也许它被删除了?Django的SQLite [英] Tablename with ID "Some_ID" doesn't exist. Perhaps it was deleted? Django Sqlite

查看:48
本文介绍了ID为"Some_ID"的表名;不存在.也许它被删除了?Django的SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库有很多表;通过主键和外键互连的三个是"Vendor_Details","Channel_Details"和"MSO_Details"

I have database with many tables; three of those which are interlinked via primary and foreign keys are "Vendor_Details" , "Channel_Details" and "MSO_Details"

models.py

class Vendor_Details(models.Model):
    class Meta:
        verbose_name_plural = "Vendor_Details"
    vendor_name = models.CharField(primary_key = True,max_length=50)
    mso_id = models.CharField(unique = True, max_length=20)

class Channel_Details(models.Model):
    class Meta:
        verbose_name_plural = "Channel_Details"
    channel_id = models.CharField(primary_key = True, max_length=20)
    vendor_name = models.ForeignKey(Vendor_Details, on_delete=models.CASCADE)
    channel_logo = models.CharField(max_length=50)
    channel_name = models.CharField(max_length=50)

class MSO_Details(models.Model):
    class Meta:
        verbose_name_plural = "MSO_Details"
    mso_id = models.ForeignKey(Vendor_Details, on_delete=models.CASCADE)
    channel_id = models.ForeignKey(Channel_Details, on_delete=models.CASCADE)
    channel_number = models.PositiveIntegerField()

所以,Channel_Details链接到带有vendor_name和MSO_Details与Vendor_Details和Channel_Details分别通过mso_id和channel_id链接.

So, Channel_Details is linked to Vendor_Details with vendor_name and MSO_Details is linked with Vendor_Details and Channel_Details with mso_id and channel_id respectively.

现在,我在Django的Administrator的MSO_Details表中,并尝试单击CHANNEL ID列的编辑图标,我得到一个新窗口,其中显示消息 ID为"CH6"的Channel_ details不存在.也许它已被删除?可能是因为channel_id是引用表的主键,并且DB不允许更改?但是,那时的信息本来应该有所不同.我该如何处理这种情况?我单击了CH_006的编辑,消息显示为CH6.我很困惑这里发生了什么,django的数据库在这里指的是什么?注意:点击添加按钮后,我可以很好地添加新的CHANNEL_DETAILS.

Now, I am inside Django's Administrator's MSO_Details table and trying to click on edit icon of CHANNEL ID column i get a new window opens with message Channel_ details with ID "CH6" doesn't exist. Perhaps it was deleted? May be this is because channel_id is primary key of reference table and DB will not allow the changes? But then the message should had been something different. How can i handle this situation? I clicked on edit for CH_006 and message shows CH6. I am confused whats going on here, what is django's DB refering to here? Note : I can very well add new CHANNEL_DETAILS after click add button.

推荐答案

最近两天我遇到了此类问题,问题是1.如果最初是在向新表单添加详细信息时,则没有添加所需的正确字段.(我在纯CharField字段中同时包含了文本和整数)

I had this kind problem for the last two days and the problem was 1. If on adding details to a new form initially, you do not add the right field required.(I was including both text and integers to a field that was only CharField)

2.再次出现错误时,另一个解决方案是删除迁移和数据库本身,然后再次创建新数据库(使用相同的数据库名称).

2.The other solution when the error came again was to delete migrations and the database itself and create a new database again(Using the same database name).

这篇关于ID为"Some_ID"的表名;不存在.也许它被删除了?Django的SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆