您的位置:首页 > 编程语言 > Go语言

Django 1.1 model中关于radio的改动

2009-09-18 13:23 295 查看
Django 1.1 model中关于radio的改动

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

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)
telphone = models.CharField('电话', max_length=20)
mobile = models.CharField('手机', max_length=11)

# class Admin: pass

class AddressAdmin(admin.ModelAdmin):
model = Address
radio_fields = {'gender': admin.HORIZONTAL}
# radio_fields = {'gender': admin.VERTICAL}
# radio_admin = True

admin.site.register(Address,AddressAdmin)
http://code.djangoproject.com/wiki/NewformsAdminBranch
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: