In send_option
(in views) variable I have name
of Send
.
I would like to have ID
of Send
How to do it? Thanks
Form:
class SendOrderForm(forms.Form):
send_option = forms.ModelChoiceField(queryset=Send.objects.all())
Model:
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)
Views:
if request.method == 'POST':
form = SendOrderForm(request.POST)
if form.is_valid():
send_option = form.cleaned_data['send_option']