title: Django ModelChoiceField: filtering query set and setting default value as an object
body: <p>I have a Django Form class defined likes this in <code>Models</code>:</p>
  
  <pre><code>class AccountDetailsForm(forms.Form):
      ...
      adminuser = forms.ModelChoiceField(queryset=User.objects.all())
  </code></pre>
  
  <p>This works OK, but it has some limitations I can't seem to work around:</p>
  
  <p>(1) I would like to use a filter on the queryset, based on a variable <code>accountid</code> passed to the form, like this:</p>
  
  <pre><code>User.objects.filter(account=accountid)
  </code></pre>
  
  <p>This can't work in the model because <code>accountid</code> can't be passed as a variable, of course.</p>
  
  <p>It follows that the <code>queryset</code> must somehow be defined in the <code>Views</code>, but as far as I can see it's a required field in the Form class.</p>
  
  <p>(2) I would like to make the default choice of <code>AccountDetailsForm</code> an object in the database, which I can select in the <code>Views</code> like this:</p>
  
  <pre><code>User.objects.filter(account=accountid).filter(primary_user=1)
  </code></pre>
  
  <p>I've tried specifying the adminuser as a default value in the form, (which works with other standard form fields, like <code>CharField</code>):</p>
  
  <pre><code>adminuser = User.objects.filter(account=accountid).filter(primary_user=1)
  
  ...
  
  form = AccountDetailsForm({'adminuser': adminuser})
  return render_to_response('accounts/edit/accountdetails.html', 
  {'form': form, 'account':account})
  </code></pre>
  
  <p>But no luck.</p>
  
  <p>Should I be using something other than <code>ModelChoiceField</code> given the flexibility I need here?</p>
  
  <p>Thanks.</p>