Django - ChoiceField - selection buttons instead of selection window

Is it possible to display the option buttons instead of the selection window (in the admin interface) for ChoiceField? Any suggestions?

+3
source share
3 answers

The following subclass ModelAdmin(in your admin.py) does the following:

class PersonAdmin(admin.ModelAdmin):
    radio_fields = {"group": admin.VERTICAL}

HORIZONTAL also possible.

From Django docs .

+5
source

djangosnippets, , , - , , , , admin. , , , .

+1

.

admin.py ModelAdmin:

from django.contrib import admin
from django.forms.widgets import RadioSelect ## originally had mistake of django.forms.extras.widgets

class SomeModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
         models.ChoiceField : dict(widget = RadioSelect) 
     }

admin.site.register(SomeModel, SomeModelAdmin)

, " ", , , . : http://docs.djangoproject.com/en/dev/ref/forms/widgets/

+1

Source: https://habr.com/ru/post/1775876/


All Articles