New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the design seems to be backward the django-rest-framework serializers. #278
Comments
Don't agree with 1). I prefer validation to raise an exception, containing the error messages. I think storing the errors in the model it's more awkward and less flexible. I don't want an external library to mess around with my data structures. What's wrong with an exception? Not really sure if 2) is needed as well, I mean, it's just trivial to implement that functionality yourself without bloating the API with extra flags. Just IMO. |
Yeah, we're open to any ideas, but in cases such as these, I would like to see some concrete examples that illustrate why the alternative is better. @hackrole, why would you store errors on the model? What's the practical benefit? And about this:
What value does
|
@bintoro,
the later is more clean.
|
@bintoro
but if you can support queryset like use many or other ways, the code may look like:
|
(1) Errors inside models instead of exceptions: Sorry but this is unlikely to happen, as it seems extremely complicated if you have a tree of models referencing other models. An exception provides all the errors in one place. (2) Queryset-like multi-instances: I think this sort of functionality should be provided by an extraneous wrapper class, not the |
I go throught some features of the both. and below was my opinion:
the validate raise error is not good. the django-rest-serializers return true or false, and store the errors in the models. this is more usable.
cannot serializers more than one field. the django-rest-serializers can use like below:
but the schematics cannot do. indeed, many ORM-lib will support both single-and-many objects. for example: the mongoengine with queryset.
3) you can call to_native() even the validate return errors.
The text was updated successfully, but these errors were encountered: