首页 > 代码库 > django Modelform表单自定义控件

django Modelform表单自定义控件

model.py内容有一个类如下:

models.Modelemail_server_ip models.CharFieldemail_server_port models.CharFieldsender models.EmailFieldreceivers models.CharFieldcopy_to models.CharField

form.py对应内容如下:

ModelFormmodel MoinitorConfig
        fields , , , , widgets TextInput,                                                ,                                                ,            TextInput,                                                  ,                                                  ,            TextInput,                                       ,                                       ,            TextInput,                                          ,                                          ,            TextInput,                                        ,                                        ,

 

views.py如下:

.method .method MoinitorConfig.objects.filterins MoinitorConfig.objects.getform MoinitorConfigForminsform MoinitorConfigFormrender_mako_context,                                   ,                                   form,

template如下:

 

% for k in form:
    ${k}
% endfor

技术分享

 

本文出自 “hooden的博客” 博客,请务必保留此出处http://hooden.blog.51cto.com/9533505/1919558

django Modelform表单自定义控件