Sunday, August 16, 2015

Re: Architectural suggestions for (Django + API)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJV0WJwAAoJEC0ft5FqUuEhSUgQAIqumNgvvEPyjnWnCEBqSH9C
UU4EEB0oUyvJTWpmFIZA7dDcCAw8Kg8mKvr6p05M/zNr9w0NKDrCcahvkRnq/eX7
+SSBEIkHO6NkHT7r5HQxj0i00cN2+S0BUFXLvk1t0bfnZY0e1iQRHA/WtXEMZjut
YBndRGG8Sa94UVw8OOjLNWMY3J4PfhmGd0d7Yiq/ji8yJwb3BwFUDUAMMOmv4HLj
+qH8U950PevqpQ7kW0x3TZeLUtFoCbQ9Q/d84YQNnr7kL/sX1uFkRRBmspmsmJ3V
62qG2uuYRoICt77zjGE4cdtfN9LB/XTSFK8QmhCRgpzAQGnV3j9CyQe6Cv/62dqD
3FBnLllq9ymelf66Co55rZzEWvriitZUzm4eWtqvdQxhr3LlaBwsvB7tyqb0NLRR
17cmhC9lQiZ2D3KuIRsopa24T6OF1pQcnpfUnRNqKvtR5iNH76JV56fJ5RgkOrTw
zhL1hHxIHfygADfzJvzL2HAJBbcx9SzAmlGdg+S2DWN80jXtDmil/iMDErUxxitO
nF31qhqwkoWB/Yg6D+tk3Q/dSsUvCR4bbBfoo7QcLJGrF5ZjkC7/8RS0eRqQ4T9S
A0x2ezhcoCmqmbKy8N2yJePXwUQnjIFGpnxb2fCruAX6guK6d+YShDaTMvNSE8RG
CHdu12/dhPBZJVVbKavN
=6T/M
-----END PGP SIGNATURE-----
Hi Julio,

On 08/16/2015 04:59 PM, julio.lacerda@m2agro.com.br wrote:
> I created a project using Django (let's call this Project A) and now I
> decided to start a new one but this time it is an API using Django REST.
> So, for now I have to refactor Project A to consume data from API, but
> in order to do that I need to duplicate all my models files in both
> projects. The question is how can I avoid this? Is there another way to
> do that?

I don't quite understand why the situation you describe requires
duplicating models files. Is the canonical data storage now in Project B
instead of Project A, and Project A gets the data via Project B's REST
API? In that case, why does Project A need those models anymore?

> I see that /moving models /from Project A to API as something natural
> but to have an empty models file in Project A I need to change some
> concepts, for removing ModelForms and put all validation logic using Form.

Well, yes, but it seems to me that those types of changes in the Project
A codebase will be required regardless, since it now wants to save the
data via a REST API, not to its own database. How does a ModelForm help
with that?

> How do you guys see this? Would you recommend something different? Is
> that a good idea?
>
> 1. Project A (Models) <---> API (same models??? How can I handle that?)
> 2. Project A (No models) <---> API (Models)

The latter. I don't understand how the first option would even work.

But if you _do_ want to share some models between two projects, for
whatever reason, you can do it the same way you'd share any other code:
put the models in a reusable app and install it in both projects.

Carl

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/55D16270.8010506%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment