Skip to content

Instantly share code, notes, and snippets.

@stephane
Created August 26, 2015 20:22
Show Gist options
  • Save stephane/40797e271521728921ff to your computer and use it in GitHub Desktop.
Save stephane/40797e271521728921ff to your computer and use it in GitHub Desktop.
How to override the widget of a field in the administration of Django
class IssueAdminForm(forms.ModelForm):
class Meta:
model = app_models.Issue
fields = ['title', 'labels']
widgets = {
'labels': app_forms.ArrayFieldSelectMultiple(
choices=app_models.Issue.LABEL_CHOICES),
}
class IssueAdmin(admin.ModelAdmin):
form = IssueAdminForm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment