How to filter the ManyToManyField or ForeignKey in modelForm?
来源:互联网 发布:three.js开发指南摘要 编辑:程序博客网 时间:2024/05/22 01:41
If you don't make some changes on modelForm, it will generate all items of related model to html.
So, if you want to only show the related items, you should add some codes to views.
def xxx_view(request):
form = XXXForm()
...
form.fields['related_field_name'].queryset = RelatedFieldModel.objects.filter(field=related_field)
...
- How to filter the ManyToManyField or ForeignKey in modelForm?
- How to get rid of the white margin in MATLAB's saveas or print outputs
- How To Check Whether Physical Standby is in Sync with the Primary or Not?
- How to solve "one or more projects in the solution were not loaded correctly" problem?
- How to fix “The system is running in low-graphics mode” Ubuntu 17.04 or 16.04
- How to get the 2D coordinate of the max or min value in matrix in matlab
- How to view the schema class or attribute definition you first have to install the Active Directory Schema snap-in
- How to remove ^M in the file
- How to change the timeout in FXCop
- How to set the style in valuelist
- How to detect the explorer in js
- How to install VIM in the MSYS?
- How to build libDTS in the MSYS?
- How to build libA52 in the MSY?
- How to build giflib in the MSYS?
- How to build libpng in the MSYS?
- How to install live555 in the MSYS?
- How to Run Hadoop in the Cloud
- v8学习笔记(七) 执行过程
- 你为谁工作-专业、专注才能做大做强
- sql2005自动备份数据库
- java时间操作函数汇总
- v8学习笔记(八) 【JS与C++互调】
- How to filter the ManyToManyField or ForeignKey in modelForm?
- servlet实现文件的上载,下载
- js 获取网址
- 游戏编程入门
- [zz] Read and write a properties file
- 正整数js正则表达式
- 设置div里的内容在最底部
- 软件版本的识别
- 关于输入框的光标