How to make interaction between different django applications on one site?

I just found out about Django apps. I want to know what on the same site if I make different applications. For example, users, profiles, polls, blogs, comments, assignments, applications, how can I manage them to make them interactive? And what should the application concept look like? I want everything to be closely related to why asking? Rails work in the REST way, so support Django support while also using applications? Maybe my questions seem a bit ambiguous because I'm new to django and some of my concepts are still confused.

Tell us what you know.

+4
source share
1 answer

The general idea is that applications should be as flexible as possible. The goal is to have fully autonomous functionality. Now, of course, this is not always possible, and many times it even makes sense to use the functionality from another application. To do this, you simply import everything you need. For example, if your blogs application should work with your Comment model in your comments application, you simply added the following to the top of the python file you are working in:

 from comments.models import Comment 

You can then use Comment as if it were defined correctly in the same file.

Regarding REST, Django views are much more fluid. You can call your opinion what you like; you only need to connect it to the correct urlpattern in urls.py. Django views can return any type of content, you just prepare the answer and tell it which mimetype is used for its operation (HTML is used by default).

+4
source

Source: https://habr.com/ru/post/1379551/


All Articles