phalt / django-api-domains

A pragmatic styleguide for Django API Projects
https://phalt.github.io/django-api-domains/
MIT License
705 stars 62 forks source link

[QUESTION] Restrictions on data types that services may return. #20

Open voyc-jean opened 4 years ago

voyc-jean commented 4 years ago

I noticed that within the styleguide and examples, service functions / methods always return a Dict. Is returning more complext data, such as model instances, permissible?

PS, the one exception is this example, but I think this may be a mistake as a dict is ultimately returned.

phalt commented 4 years ago

Good question:

For APIs:

All data returned from APIs must be serializable.

For Services there is no restriction :)

voyc-jean commented 4 years ago

Great, thanks @phalt. I've created a PR [#21] which includes a few fixes, including the issue with the example which I originally mentioned.