1

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ように見えますが、例外を適切に発生させ、それらの例外を介して何が問題なのかを説明する方法がわかりません。何か案は?

4

1 に答える 1

1

私はアルファベット順にドキュメントを読んでいて、最終的に出くわしました: http://django-tastypie.readthedocs.org/en/latest/validation.html

于 2012-09-05T16:37:05.733 に答える