Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LocModelForm(forms.ModelForm):
- def __init__(self,*args,**kwargs):
- super(LocModelForm,self).__init__(*args,**kwargs)
- self.fields['icons'] = forms.ModelChoiceField(queryset = Photo.objects.filter(galleries__title_slug = "markers"))
- self.fields['icons'].widget.attrs['class'] = 'mydds'
- class Meta:
- model = Loc
- widgets = {
- 'icons' : forms.Select(attrs={'id':'mydds'}),
- }
- class Media:
- css = {
- "all":("/media/css/dd.css",)
- }
- js=(
- '/media/js/dd.js',
- )
- class LocAdmin(admin.ModelAdmin):
- form = LocModelForm
- class MySelect(forms.Select):
- def render_option(self, selected_choices, option_value, option_label):
- # look at the original for something to start with
- return u'<option whatever>...</option>'
- class LocModelForm(forms.ModelForm):
- icons = forms.ModelChoiceField(
- queryset = Photo.objects.filter(galleries__title_slug = "markers"),
- widget = MySelect(attrs = {'id': 'mydds'})
- )
- class Meta:
- # ...
- # note that if you override the entire field, you don't have to override
- # the widget here
- class Media:
- # ...
Add Comment
Please, Sign In to add comment