title: Django: Select a valid choice. That choice is not one of the available choices
body: <p>I have a nested choice field:
  The top one is used to select a smartphone brand and the bottom one is used to select a smartphone model of the said brand.</p>
  <p>The problem I face is such that when restricting the bottom choice using AJAX, my form is invalid. However, the POST request with and without restriction are exactly the same:</p>
  <p>No restriction:</p>
  <pre><code>{'name': 'Ok iPhone 12 Mini', 'price': Decimal('345'), 'color': &lt;Color: Red&gt;, 'condition': &lt;Condition: Refurbished by manufacturer&gt;, 'storage': &lt;StorageChoice: 128&gt;, 'phone_model': &lt;PhoneModel: iPhone 12 Mini&gt;, 'description': '...', 'image': &lt;InMemoryUploadedFile: pic.jpg (image/jpeg)&gt;}
  </code></pre>
  <p>With restriction:</p>
  <pre><code>{'name': 'Ok iPhone 12 Mini', 'price': Decimal('345'), 'color': &lt;Color: Red&gt;, 'condition': &lt;Condition: Refurbished by manufacturer&gt;, 'storage': &lt;StorageChoice: 128&gt;, 'description': '...', 'image': &lt;InMemoryUploadedFile: pic.jpg (image/jpeg)&gt;, 'phone_model': &lt;PhoneModel: iPhone 12 Mini&gt;}
  </code></pre>
  <p>The only difference I can see is order, which should not matter in the case of a dictionary.</p>
  <p><strong>views.py:</strong></p>
  <pre><code>def product_add(request):
      form = AddProductForm()
      if request.method == &quot;POST&quot;:
          form = AddProductForm(request.POST, request.FILES)
          form.is_valid()
          form.cleaned_data['phone_model'] = PhoneModel.objects.get(id=request.POST['phone_model'])
          form.cleaned_data.pop('make', None)
          print(form.cleaned_data)
          if form.is_valid():
              form.cleaned_data['seller'] = request.user.customer
              Product.objects.create(**form.cleaned_data)
          else:
              print(form.errors)
      cart = get_cart(request)
      context = {'form': form, **cart}
      return render(request, 'store/product_add.html', context)
  
  def load_models(request):
      make_id = request.GET.get('make')
      models = PhoneModel.objects.filter(phone_make=make_id)
      return render(request, 'part/product_add_model_options.html', {'models': models})
  </code></pre>
  <p><strong>forms.py:</strong></p>
  <pre><code>class AddProductForm(forms.ModelForm):
      class Meta:
          model = Product
          fields = ['name', 'price', 'color', 'condition',
                    'storage', 'phone_model', 'description', 'image']
  
      def __init__(self, *args, **kwargs):
          super().__init__(*args, **kwargs)
          make = forms.ModelChoiceField(
              queryset=PhoneMake.objects.all(), required=False)
          self.fields['make'] = make
          self.fields['phone_model'].queryset = PhoneModel.objects.none()
          if 'make' in self.data:
              try:
                  make_id = int(self.data.get('make'))
                  self.fields['phone_model'].queryset = PhoneModel.objects.filter(
                      phone_make__phone_make=make_id)
              except Exception as e:
                  print(e)
  </code></pre>
  <p><strong>product.html</strong> (used with Jquery script to insert &quot;options&quot; into this &quot;select&quot;):</p>
  <pre><code>  &lt;select name=&quot;phone_model&quot; required id=&quot;id_model&quot;&gt; &lt;/select&gt;
  </code></pre>
  <p><strong>product_option.html:</strong></p>
  <pre><code>&lt;option value=&quot;&quot;&gt;---------&lt;/option&gt;
  {% for model in models %}
  &lt;option value=&quot;{{ model.id }}&quot;&gt;{{ model }}&lt;/option&gt;
  {% endfor %}
  </code></pre>