modify django admin field to use specific queryset and form widget


/ Published in: Django
Save to your folder(s)



Copy this code and paste it in your HTML
  1. from django import forms
  2. from django.contrib.admin import widgets
  3.  
  4. class ScheduleAdminForm(forms.ModelForm):
  5.  
  6. profiles = forms.ModelMultipleChoiceField(
  7. widget = widgets.FilteredSelectMultiple('Profiles',False),
  8. queryset = Profile.active_objects.all(),
  9. help_text = "this doesn't show. bummer.")
  10.  
  11. class Meta:
  12. model = Schedule
  13.  
  14.  
  15. class ScheduleAdmin(admin.ModelAdmin):
  16.  
  17. form = ScheduleAdminForm
  18.  
  19. admin.site.register(Schedule, ScheduleAdmin)

URL: http://snipt.net/mandric/modify-admin-field-to-use-specific-queryset-and-form-widget/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.