How to pass initial parameter to django's ModelForm instance?

前端 未结 4 1619
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 05:01

The particular case I have is like this:

I have a Transaction model, with fields: from, to (both are ForeignKeys to auth.Use

4条回答
  •  粉色の甜心
    2021-01-31 05:49

    Pass the user into the __init__ of the form, and then call super(…). Then set self.fields['from'].queryset to user.peers

提交回复
热议问题