Django: Generic detail view must be called with either an object pk or a slug

后端 未结 6 967
别那么骄傲
别那么骄傲 2021-02-01 14:26

Getting this error when submitting the form associated with this view. Not sure what exactly is the problem, considering I have a form with a very similar structure and it works

6条回答
  •  被撕碎了的回忆
    2021-02-01 15:08

    As Alex suggests: for default Django behaviour you have to use "pk" in your url pattern.

    If you wish to change the object identifier for the primary key "pk" to a different name, you can define pk_url_kwarg. This is available since Django 1.4.

提交回复
热议问题