A
A
Anton2016-12-18 01:30:36
Django
Anton, 2016-12-18 01:30:36

Explain the essence of applications in django?

Hello, I'm studying django, and as I understand it, there can be several applications in a project, could you give an example of a project where several applications are used, and answer my question whether these applications can be somehow related to each other, for example a general model or a general view, and where to store them in such cases?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
tema_sun, 2016-12-18
@tema_sun

For example:
The project is the entire site.
The blog is an application.
The forum is an application.
Photo gallery is an application. Well, and so on.
They may be related. For example, users for a forum and a blog can be the same.
General view - I can not immediately think of why this is. General models - of course. Store models in their respective applications, and link them via foreign key if necessary.

R
Roman Kitaev, 2016-12-18
@deliro

The question is good. I once asked myself the same. And I came to the conclusion that I will select only reusable apps in apps, that is, applications should not have connections outside of themselves (not counting the user). I singled out applications such as chat, a captcha generator, etc., and kept everything else in an app with the meaningful name core.
One fine day, in one beautiful project with this same core app, there were about 30 models and almost a hundred views. It was decided to split the models and views into submodules (instead of the views.py file, a folder was created with the __init__.py file and other files categorized by these same views, the same with models). It was then that I saw the light and realized why apps are really needed.

I
Ivan, 2016-12-22
@ATNC

An application is an "encapsulation" of modules that deal with tasks of the same type.
For example, the application "auth" is engaged in work with the user - authorization, authentication, registration.
The "blog" application is engaged in writing, publishing posts - this means that this application contains code that is responsible only for the blog entities.
The blog has posts, and each post can be linked to a user. It turns out that in this case the "auth" application interacts with the "blog" application.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question