Sunday, August 16, 2015

Re: About local apps communication

Ah yes, my answer only applies if you have two separate instances of Django running with separate databases. That was my assumption since the full database is available to all apps within a single Django instance as Stephen mentioned.

-James

On Aug 16, 2015 3:55 AM, "Stephen J. Butler" <stephen.butler@gmail.com> wrote:
These are all in the same project, right? In your app2 just do:

from app1.models import MyUserModel

Or maybe factor out the logic of app1/resources/user to a function and do from app2:

from app1.utils import get_user_logic

There's no special communication between Django apps required. All the code from every app in your project (INSTALLED_APPS) is loaded into/available from your current interpreter instance.

On Sun, Aug 16, 2015 at 5:33 AM, <durirompepc@gmail.com> wrote:
I had searched in the web about local communication between apps, but I didn't find anything (or, at least, didn't catch it) about calling an app from another. Let's say I've this:
http://localhost:8000/app1/resources/user?id=123
http://localhost:8000/app2/list_users

Each app (by the way, first time doing a really RESTfull service, maybe I'm wrong with the style) have their models. app1 have a table for user, and app2 needs to communicate with it to list all the users (gived or not a QUERYSTRING for filtering). From app2.views, how could I get that data in a Django way?

--
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/34bdde3e-6422-49e0-9285-9113ed0abf7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAD4ANxUcz8urnNam-iLgacB0hMOjuS6EqFQbfGMy1%2BBbtfxdSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CA%2Be%2BciVGUgEAkiAOwypFnNKhhD9LKPwD1aea32B%3Dv7%3DgXBfQPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment