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
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
相关文章推荐
- django关于URL、Template、Model的一些高级应用
- 关于Django model 与json序列的转换
- 关于django model postgres的json字段编码问题
- 关于DjangoRuntimeError: Model class doesn't declare an explicit app_label
- 关于django model_set 的惨痛教训
- 关于django中ModelForm的instance
- django关于model查询
- 关于django内置的ModelForm小记
- GIT学习笔记——1.1 起步 - 关于版本控制
- 关于django 工程创建找不到 django-admin.py 文件问题
- django model数据类型样例
- 关于关于高博3d2d程序报错的改动
- django在model中添加字段报错
- ④Windows7 Django1.5--创建app,建立model,
- 自定义 Django的User Model,扩展 AbstractUser类注意事项
- Django--model模型绑定_数据库操作
- 关于Swing的Model
- tornado with MySQL, torndb, django model, SQLAlchemy ==> JSON dumped
- Django forms 关于select和checkbox设置初始选中值
- 【C++】1.1 VS中关于工程的使用