from django import forms
from registration.forms import RegistrationFormUniqueEmail

from preferences.models import Preferences

from opencivicdata.models.people_orgs import Person


class CustomModelFilter(forms.ModelChoiceField):
    def label_from_instance(self, obj):
        return "%s" % (obj.name)

class PreferencesForm(forms.ModelForm):
    senator = CustomModelFilter(queryset=Person.objects.filter(memberships__organization__name='Florida Senate'))

    class Meta:
        model = Preferences
        fields = ['representitive', 'senator', 'street_line1', 'street_line2',
                  'zipcode', 'city', 'state']
from django import forms
from registration.forms import RegistrationFormUniqueEmail

from preferences.models import Preferences

from opencivicdata.models.people_orgs import Person


class CustomModelFilter(forms.ModelChoiceField):
    def label_from_instance(self, obj):
        return "%s" % (obj.name)

class PreferencesForm(forms.ModelForm):
    senator = CustomModelFilter(queryset=Person.objects.filter(memberships__organization='Florida Senate'))

    class Meta:
        model = Preferences
        fields = ['representitive', 'senator', 'street_line1', 'street_line2',
                  'zipcode', 'city', 'state']
--- 
+++ 
@@ -11,7 +11,7 @@
         return "%s" % (obj.name)
 
 class PreferencesForm(forms.ModelForm):
-    senator = CustomModelFilter(queryset=Person.objects.filter(memberships__organization='Florida Senate'))
+    senator = CustomModelFilter(queryset=Person.objects.filter(memberships__organization__name='Florida Senate'))
 
     class Meta:
         model = Preferences
Add maybe right connection for name
