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.

  1. how use radio button in admin?
  2. also, how make selected value in admin?
  3. 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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -