Thanks for the responses. Now I'll try to explain ahead:

If both apps are running on the same host (or more concisely, both apps can 
> access the database for app1), why not just add a database router to app2 
> and have it pull the information directly?
> https://docs.djangoproject.com/en/1.8/topics/db/multi-db/
> Another option would be to have logic in app2 that can query against app1 
> via typical HTTP REST requests (perhaps triggered by an HTTP call to a view 
> in app2 if the info needs to be pulled on demand), using app2 as if it were 
> a regular client for app1.
> A third option if the information is synced on a regular basis would be to 
> write Django management commands and run them on a schedule via cron to 
> pull the data from app1 to app2.
> These options are in order of preference, as direct DB access is the 
> fastest and easiest to manage, but may be negatively affected if the schema 
> changes in app1.
>
 

[...]

 

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

 
I think that the optimal option would be the second one (doing a request), 
because of the background of the apps maybe the client would only use the 
user app, for example. And no, it'll be just one instance of Django for the 
apps.


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. 


That's the point, they are in the same project, and supossed to be (because 
it'll be a package with more than one app). I though that doing something 
with *INSTALLED_APPS* would work, but didn't know about that *import*. And 
about the factoring function, yeah, it is supossed to be REST, so a 
*utils.py* or *rest.py* file should do the work.


Thanks again both.

-- 
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+unsubscr...@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/2aec1f5c-790c-44f6-9302-9c85b817cbef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to