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.
精彩评论