Django 1.1 model中关于radio的改动
Django 1.1 model中关于radio的改动
1
#coding=utf-8
2
from django.db import models
3![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
# Create your models here.
5![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
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![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
class Admin: pass
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
现在要写成
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)
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)