Django admin field choices render as multiple checkbox -
i'm trying customise django admin page. want single model field render choices passed checkboxselectmultiple, can't work.
here relevant part of models.py
:
from django.db import models django.contrib.auth.models import user django.contrib import admin class event(models.model): group_owner_choices = ( ('vcoe', "vcoe"), ('cssi', 'cssi'), ('essc', "essc"), ('tmscc', "tmscc"), ('inmc', "inmc"), ('ccs7', "ccs7"), ('ias', "ias"), ) group_owner = models.booleanfield(choices=group_owner_choices, blank=true, default=false)
i can't use django formfield_overrides
(https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.modeladmin.form) because have more 1 booleanfield , keep other booleanfield's intact.
here found other questions
from django.contrib import admin .models import event django import forms class eventgroupowneradminform(forms.modelform): def __init__(self, *args, **kwargs): super(eventgroupowneradminform, self).__init__(*args,**kwargs) self.fields["group_owner"].widget = forms.widgets.checkboxselectmultiple() class eventadmin(admin.modeladmin): form = eventgroupowneradminform admin.site.register(event , eventadmin)
but field doesnt render anything. help?
Comments
Post a Comment