Limit values in the modelformset field

前端 未结 2 1962
别跟我提以往
别跟我提以往 2021-01-28 00:06

I\'ve been trying to solve this problem for a couple of days now, getting quite desperate. See the commented out code snippets for some of the things I\'ve tried but didn\'t wor

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-28 00:49

    Category.objects.filter(user=request.user)
    

    returns a list object for the initial value in your form which makes little sense.

    Try instead

    Category.objects.get(user=request.user)
    

    or

    Category.objects.filter(user=request.user)[0]
    

提交回复
热议问题