0
我forms.pyDjango的異常值: '模塊' 對象有沒有屬性 'ModelsChoiceField'
from django import forms
from django.forms import Form
from .models import LedON, Device
class DownlinkForm(forms.Form):
Device_id = forms.ModelChoiceField(queryset = Device.objects.all())
Time_intervall = forms.IntegerField()
Led1 = forms.ModelsChoiceField(queryset = LedON.objects.all())
我的models.py
from django.db import models
from app.models import *
from django import forms
from django.forms import ModelChoiceField
class LedON(models.Model):
Ledon = models.CharField(max_length = 50)
class Meta:
verbose_name = 'ledon'
def __str__(self):
return "%s" % (self.Ledon)
class DevEUIModelChoiceField(ModelChoiceField):
def label_from_instance(self, obj):
return obj.DevEUI
class LedonModelChoiceField(ModelChoiceField):
def label_from_instance(self, obj):
return obj.Ledon
設備對象的工作,並告訴我ModelChoiceField
。 但我不明白爲什麼Ledon不工作。
:D那麼簡單...我是盲人thx –