Reputation: 29511
I'm using the admin's filteredselectmultiple
widget in my form:
students = forms.ModelMultipleChoiceField(queryset=Student.objects.all(),widget=FilteredSelectMultiple("Subjects",is_stacked=False))
However, there is no styling for the widget like in the admin page.
I've included form.media
in my template, but is aware that no css files are included in my page.
Question is: what css file do I need to include in my template? Do I have to add them for every django widget i use?
Upvotes: 1
Views: 1794
Reputation: 2264
I have no idea why the required css file is not included in the widget media by default, as form.media is supposed to collect all media files for the widgets used in that form... I quickly tried it out myself and run into the same problem.
The css file that you would need to include seems to be widgets.css. Adding this to my form made it work for me:
class Media:
css = {
'all': ['{0}css/widgets.css'.format(settings.ADMIN_MEDIA_PREFIX), ]
}
Let me know if this answers your question! I'm new to SO so any feedback is welcome:)
Upvotes: 2
Reputation: 1523
Can you tried override the widget?
I have an app and I override the textArea widget to use the TinyMCE editor. Like this
Upvotes: 0
Reputation: 7138
I don't know the answer, but I know how I'd find it. I'd put that widget in the admin (maybe you already have an example) and then load the page it's on in my browser. Then I'd open up Chrome Developer Tools or Firebug in Firefox and use the element inspector. Select the HTML element from the widget in question and look in the CSS pane to see what CSS files are contributing to its layout. You'll also see what rules they're matching - quite possibly you already have the file you need but it needs to be inside a particular container to layout properly.
Upvotes: 0