Django 1.1 model中关于radio的改动

it2024-07-29  75

Django 1.1 model中关于radio的改动

 1 # coding=utf-8  2 from  django.db  import  models  3  4 #  Create your models here.  5  6 class  Address(models.Model):  7 name  =  models.CharField( ' 姓名 ' , maxlength = 6 , unique = True)  8 gender  =  models.CharField( ' 性别 ' , choices = (( ' M ' ' ' ), ( ' F ' ' ' )),  9 maxlength = 1 , radio_admin = True) 10 telphone  =  models.CharField( ' 电话 ' , maxlength = 20 ) 11 mobile  =  models.CharField( ' 手机 ' , maxlength = 11 ) 12 13 class  Admin:  pass

现在要写成

 1  #  coding=utf-8  2  from  django.db  import  models  3  from  django.contrib  import  admin  4   5  #  Create your models here.  6  class  Address(models.Model):  7  name  =  models.CharField( ' 姓名 ' , max_length = 10 , unique = True)  8  gender  =  models.CharField( ' 性别 ' , choices = (( ' M ' ,u ' ' ),( ' F ' ,u ' ' )),  9  max_length = 1 ) 10  telphone  =  models.CharField( ' 电话 ' , max_length = 20 ) 11  mobile  =  models.CharField( ' 手机 ' , max_length = 11 ) 12  13  #  class Admin: pass 14  15  class  AddressAdmin(admin.ModelAdmin): 16  model  =  Address 17  radio_fields  =  { ' gender ' : admin.HORIZONTAL} 18  #  radio_fields = {'gender': admin.VERTICAL} 19  #  radio_admin = True 20  21  admin.site.register(Address,AddressAdmin)

http://code.djangoproject.com/wiki/NewformsAdminBranch

转载于:https://www.cnblogs.com/auxten/archive/2009/09/18/1569396.html

相关资源:数据结构—成绩单生成器
最新回复(0)