Last active
May 2, 2018 03:38
-
-
Save cheng10/4198f933b0e5c423b578546a324836d4 to your computer and use it in GitHub Desktop.
django FilteredSelectMultiple widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# forms.py | |
from django.contrib.auth.models import User | |
from django import forms | |
from django.contrib.admin.widgets import FilteredSelectMultiple | |
class AdvertiserAdminForm(forms.ModelForm): | |
user = forms.ModelMultipleChoiceField( | |
required=False, | |
queryset=User.objects.all(), | |
widget=FilteredSelectMultiple('User', is_stacked=False), | |
) | |
# admin.py | |
from django.contrib import admin | |
class AdvertiserAdmin(admin.ModelAdmin): | |
form = AdvertiserAdminForm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment