标签:多选框 isp 数据 lan 英语 model ice filter git
1.admin后台管理数据表,首先需要在admin.py中注册models
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.contrib import admin from .models import test_table from .models import person ‘‘‘ class ngo_base_info_admin(admin.ModelAdmin): list_display = (‘name‘, ‘abstrat‘, ‘tech_person‘)#显示的信息 search_fields = (‘name‘,)#查找 list_filter = (‘name‘,)#过滤器 admin.site.register(ngo_base_info, ngo_base_info_admin)#注册 ‘‘‘ # Register your models here. admin.site.register(test_table) admin.site.register(person)
2.下拉框的使用
models这样写:
class person(models.Model): sex_type = ((‘male‘, u‘男‘), (‘female‘, u‘女‘)) sex = models.CharField(u"性别", choices=sex_type, max_length=32)
显示效果:
3.多选框的使用
其中主要使用了MultiSelectField模块,模块项目地址:https://github.com/goinnn/django-multiselectfield
models:
from django.db import models from multiselectfield import MultiSelectField # Create your models here. class test_table(models.Model): language_choices = ((‘chinese‘, u‘汉语‘), (‘english‘, u‘英语‘), (‘french‘, ‘法语‘)) language = MultiSelectField(u"使用语言", choices=language_choices,null=True,blank=True)
显示效果:
标签:多选框 isp 数据 lan 英语 model ice filter git
原文地址:http://www.cnblogs.com/liangping/p/7611169.html