I
I
infoguides2020-06-29 09:25:08
Django
infoguides, 2020-06-29 09:25:08

How to organize app and dependencies in Django?

I can not understand what is app within the application?

Here I have a site where users can register. It is clear that I have an app called users, it has a user model, profile, and so on.

Here I have an app for example excursions where I store models, forms and views for excursions from users.

And, for example, where should be the model Country, City, and so on, which applies to the entire application, can be associated with both the user and the tour?

It turns out that my models, regardless of where they are located physically in which app can be used in each other?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2020-06-29
@bacon

It's more about sharing and reusing code. Those. you can, for example, use the app user in another project, this is how "batteries" work, although of course this requires some experience.
You can generally dump everything in one app, or you can make a separate app for each model, but these are extremes.

D
Dmitry, 2020-06-29
@pyHammer

infoguides in fact, you can do as you like.
Usually I always create a core application , whenever I need an API, I create an api application (api can be pulled out at any time and nothing will break). As for other applications, there will always be dependence on each other. Models Country, City I would put in the application geography .
Here you need to find a golden mean. If Country will be used in several applications, then it is better to move it to a separate application. Everything that is not classified, I dump in core .
It is also logical to move the blog application into a separate application. And also put the shop in a separate one.
That is, a sufficiently voluminous functionality can be moved into a separate application.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question