Hi all,

I'm trying to enhance a form in the admin site for a given model (Django
1.3). The relevant part of the model is the following

class Project(models.Model):
[...]
    icon = models.ForeignKey(Icon, null=True)
[...]

and the admin is a simple call to admin.site.register().

This way I get a very nice form with a drop down menu listing all the Icon
object unicode() calls.

I would like to replace the widget with an image drop down menu made with
javascript, so I did the following

class AdminImageSelectorWidget(forms.Select):
    pass

class ProjectForm(forms.ModelForm):
    icon = forms.ChoiceField(widget=AdminImageSelectorWidget)
    class Meta:
        model = Project

class ProjectAdmin(TranslationAdmin):
    form = ProjectForm


which is basically just a wrap of the existing structure: by customizing
the render() method of AdminImageSelectorWidget I think I should be able to
get what I want.

First question: is this the correct way to achieve a widget customization?
Second question: by doing this I lose the useful "+" button near the drop
down menu, which lets the users to add a new object. I found that the class
behind this button is RelatedFieldWidgetWrapper, but I do not understand if
I can use it on my widget and how.

Someone can enlighten me?
Thank you very much in advance

Leo

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to