Siva Arunachalam
Siva Arunachalam

Reputation: 7740

Django - models.CharField- choices - Option Buttons instead of Select box

For models.CharField(), we use to give a choices attribute. Normally these choices will be displayed in select box. Is it possible to display the option buttons instead of select box (in admin interface)? Any suggestions?

status = models.CharField(max_length = 25, choices = (('IN PROGRESS', 'IN PROGRESS'),('COMPLETED','COMPLETED')))

Upvotes: 0

Views: 1585

Answers (1)

jbaums
jbaums

Reputation: 27388

The following ModelAdmin subclass (in your admin.py) does what you're after:

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

HORIZONTAL is also possible.

From the Django docs.

Upvotes: 2

Related Questions