开发者

Accessing database objects in Django form cleaner

Is there a way to access the dat开发者_运维技巧abase object from the django form cleaner? Or at least the URL to which the form data was posted? If I can get the URL, I can query for the database object.

My use case is that, I have a form that should raise an error if the database object from which the form was generated is in some particular state.


Yes - take a look at self.instance from inside your form's clean method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜