在send_option
(视图中)我有的变量name
中Send
。我想ID
拥有Send
怎么做?谢谢
形式:
class SendOrderForm(forms.Form):
send_option = forms.ModelChoiceField(queryset=Send.objects.all())
模型:
class Send(models.Model):
name = models.CharField(max_length=50)
price = models.DecimalField(max_digits=5, decimal_places=2)
time = models.CharField(max_length=150)
意见:
if request.method == 'POST':
form = SendOrderForm(request.POST)
if form.is_valid():
send_option = form.cleaned_data['send_option']