Here are the examples of the python api django.forms.models.ModelChoiceField taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : Uninett
Copyright GNU General Public License v3.0
Author : Uninett
def __init__(self, account, *args, **kwargs):
super(OrganizationAddForm, self).__init__(*args, **kwargs)
if account:
query = Organization.objects.exclude(
id__in=account.organizations.all())
else:
query = Organization.objects.all()
self.fields['organization'] = forms.models.ModelChoiceField(
queryset=query, required=True, label='')
self.helper = FormHelper()
self.helper.layout = Layout(
Field('organization', css_clast='select2'),
Submit('submit_org', 'Add organization', css_clast='postfix')
)
0
View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : Uninett
Copyright GNU General Public License v3.0
Author : Uninett
def __init__(self, account, *args, **kwargs):
super(GroupAddForm, self).__init__(*args, **kwargs)
if account:
query = AccountGroup.objects.exclude(
id__in=account.accountgroup_set.all())
else:
query = AccountGroup.objects.all()
self.fields['group'] = forms.models.ModelChoiceField(
queryset=query, required=True, label='')
self.helper = FormHelper()
self.helper.layout = Layout(
Row(
Column(Field('group', css_clast='select2'),
css_clast='medium-8'),
Column(Submit('submit_group', 'Add membership',
css_clast='postfix'),
css_clast='medium-4')
)
)