我是django的新手,並且有點問題。我爲小型項目創建了一個簡單的視圖,模板和模型。當我在'投票'應用程序中要求輸入模型時,我得到Vote_Type不存在的錯誤。我不明白爲什麼它會查找Vote_Type而不是鍵入數據庫。django中不存在App_Model
所以我去尋找一個問題,現在我試圖從python控制檯創建模型類型的數據庫對象我得到了同樣的錯誤。
這是我的模型:
from django.db import models
from django.utils import timezone
# Create your models here.
class Voted_Object(models.Model):
Voted_Object_name = models.CharField(max_length=50)
Voted_Object_image = models.ImageField
Voted_Object_rating = models.IntegerField(default=0)
Voted_Object_Id = models.IntegerField
class Type(models.Model):
pub_date = models.DateTimeField('date published')
Type_name = models.CharField(max_length=50)
Type_Id = models.IntegerField
,這是我得到的錯誤,當我嘗試在Python控制檯執行Type.objects.all()。
關係 「Vote_type」 不存在 LINE 1: 「 」 「 」...... te_type PUB_DATE「,」 Vote_type TYPE_NAME「 FROM」 Vote_type ..
什麼是錯的我碼?爲什麼Django的尋找Vote_Type代替
你運行過'makemigrations'和'migrate'嗎? – Wtower
我確定我有,但讓我檢查一遍。 – Vato