The frontend of this project will have business rules built in using JS but the backend of this app which is built in tastypie will enforce these rules. Putting rules in models seems a bit messy and it would be nice to have the rules somewhere in each ModelResource
class.
Which methods should I override and how should I best report restrictions and exceptions back?
The type of logic will be along the lines of
if field_x = 5 and request.user != 2:
complain and don't process request
send back error
メソッドはチェックを行うのに適した場所のhydrate
ように見えますが、例外を適切に発生させ、それらの例外を介して何が問題なのかを説明する方法がわかりません。何か案は?