1 class AuthorForm(forms.ModelForm):
2 exclude_states = ['AS', 'GU', 'MP', 'VI',]
3 def __init__(self, *args, **kwargs):
4 # initalize form
5 super(AuthorForm, self).__init__(*args, **kwargs)
6
7 # rebuild choices
8 w = self.fields['state'].widget
9 choices = []
10 for key, value in w.choices:
11 if key not in self.exclude_states:
12 choices.append((key, value))
13 w.choices = choices
14
15 class AuthorAdmin(admin.ModelAdmin):
16 form = AuthorForm