我不斷收到一個錯誤Django:未找到字段?
ImproperlyConfigured at /messages/compose/
Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form ComposeForm needs updating.
我完全理解了該錯誤指出,但是我不明白爲什麼它顯示在第一位呢?
這是形式的Django要我更新:
from django import forms
from .models import DirectMessage
class ComposeForm(forms.ModelForm):
class Meta:
model = DirectMessage
,這裏是我的模型(完整的字段):
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
user_obj = User.objects.get(username = 'jess')
class DirectMessage(models.Model):
subject = models.CharField(max_length =150)
body = models.CharField(max_length =3000)
sender = models.ForeignKey(User, related_name='sent_direct_messages', null=True, blank=True)
receiver = models.ForeignKey(User, related_name='recieved_direct_messages', null=True, blank=True)
sent = models.DateTimeField(auto_now_add=False, auto_now=False, null=True, blank=True)
read = models.DateTimeField(auto_now_add=False, auto_now=False, null=True, blank=True)
def __unicode__(self):
return self.subject
也許有一個與我的語法有問題還是我米錯過了一個明顯的根本性錯誤。任何幫助將不勝感激,讓我知道如果你需要任何更多的信息/背景。謝謝!
ahhh,看起來像在我的壓力狀態我誤解了錯誤。讓我用我的表單更新這個問題 – Jesssssss