Posted By

magicrebirth on 01/26/10


Tagged

form admin django queryset


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

leachypeachy


modify django admin field to use specific queryset and form widget


 / Published in: Django
 

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

  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)

Report this snippet  

You need to login to post a comment.