我有一个像这样的django模型 -
class Transaction(models.Model):
date = models.DateField()
type = models.IntegerField(choices=TRANSACTION_TYPE)
distributor = models.ForeignKey(Distributor)
second_party = models.CharField(max_length=100)
route = models.ForeignKey(DistributionRoute)
total_price = models.FloatField()
def __str__(self):
return self.date + " " + " " +self.total_price
我试图从这个模型中创建一个表单 -
class transactionForm(forms.ModelForm):
class Meta:
model = Transaction
fields = ['date', 'type', 'distributor', 'second_party', 'route', 'total_price']
但我经常遇到以下错误 -
File "/home/itsd/sts/transaction/forms.py", line 5, in <module>
class transactionForm(forms.ModelForm):
File "/home/itsd/venv/lib/python3.5/site-packages/django/forms/models.py", line 247, in __new__
opts.field_classes)
File "/home/itsd/venv/lib/python3.5/site-packages/django/forms/models.py", line 133, in fields_for_model
opts = model._meta
AttributeError: 'tuple' object has no attribute '_meta'
我被困在这里好几个小时。这个问题的原因是什么?