[英]How to pass parameters to a form from a class based View with Django 1.8?
excuse my english 请问我的英语
I'd like to pass a parameter to the constructor of a form from a FormView. 我想将参数从FormView传递给表单的构造函数。 But, because when I use class based views, I'm not the one that create the form object so I am unable to do it this way .
但是,因为当我使用基于类的视图时,我不是创建表单对象的视图,因此无法以这种方式进行操作。
I know maybe the best thing to would be to use a function view instead of a class based view, but does anyone know a way to do it using class based views ? 我知道也许最好的办法是使用函数视图而不是基于类的视图,但是有人知道使用基于类的视图吗?
你不说你使用的是什么类型的基于类视图,但任何继承FormMixin有方法get_form_kwargs
正是这个目的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.