开发者

Django RadioButtons with icons and not label?

开发者 https://www.devze.com 2022-12-31 10:43 出处:网络
i have an a开发者_C百科pp that have 2 fields: company_name and logo, i\'m displaying the companies like radiobutton in my Form from Model, but i want to show the logo company instead of the company la

i have an a开发者_C百科pp that have 2 fields: company_name and logo, i'm displaying the companies like radiobutton in my Form from Model, but i want to show the logo company instead of the company label (company name)

Any idea ?

My forms:

class RecargaForm(ModelForm):
    compania = forms.ModelChoiceField(queryset=Compania.objects.all(), initial=0 ,empty_label='None', widget=forms.RadioSelect()) 

    class Meta:
        model = Recarga

Thanks :)


You could try something similar to the technique I propose in the answer to this (my own) question: How do I create a Django form that displays a checkbox label to the right of the checkbox?

Instead of writing a filter that flips the markup around, you'll need to somehow get the filter to replace the labels with the appropriate images.

Admittedly, this sounds kinda awkward to work with.

0

精彩评论

暂无评论...
验证码 换一张
取 消