Django: Admin: changing the widget of the field in Admin -
i have model boolean value that:
class tagcat(models.model): by_admin = models.booleanfield(default=true)
this appears checkbox in admin.
- how use radio button in admin?
- also, how make selected value in admin?
- also, want default value opposite, when non-admin user adds
tagcat
. field should hidden him.
can tell me how this? django documentation doesn't seem go in such details.
update 1: code gets me done 1) (don't forget tot pass choices booleanfield in model)
from main.models import tagcat django.contrib import admin django import forms class mytagcatadminform(forms.modelform): class meta: model = tagcat widgets = { 'by_admin':forms.radioselect } class tagcatadmin(admin.modeladmin): form = mytagcatadminform admin.site.register(tagcat, tagcatadmin)
the radio buttons appear ugly , displaced, @ least, work
2) solved following info in mymodel.py:
byadmin_choices = ( (1, "yes"), (0, "no"), ) class tagcat(models.model): by_admin = models.booleanfield(choices=byadmin_choices,default=1)
Comments
Post a Comment