码迷,mamicode.com
首页 > 编程语言 > 详细

Python django admin 替换表单控件

时间:2015-07-01 17:53:18      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

测试版本:

Python 2.7 Django 1.6.2  

 

models.py

from django.db import models

class Article(models.Model):
    title = models.CharField(u文章标题, max_length=120, blank=True)
    summary = models.CharField(u文章摘要, max_length=255, blank=True)

 

admin.py

from django.contrib import admin
from django.forms import forms, models

class ArticleAdminForm(models.ModelForm):
    class Meta:
        model = Article
        widgets = {
            summary: forms.Textarea(), # 修改表单控件为文本域
        }

class ArticleAdmin(admin.ModelAdmin):
    form = ArticleAdminForm
    list_display = [id, title, summary]
    #...

 

原文地址:

http://www.cnblogs.com/zhangbo127/p/4613556.html

参考地址:

http://timonweb.com/snippets/override-field-widget-in-django-admin-form/

Python django admin 替换表单控件

标签:

原文地址:http://www.cnblogs.com/zhangbo127/p/4613556.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!