F
F
FeNUMe2010-11-06 23:15:46
Django
FeNUMe, 2010-11-06 23:15:46

Organizing django project code, linking apps?

It became interesting how someone organizes their django projects:
create several applications (one for logical sections ala blog, contacts, news, etc.) and create models and views in each separately;
store all code in the root of the project, separating logical sections by splitting models and views into files, and only transfer reusable code to applications;
other options;?
If you produce applications, how do you organize the interaction between them (it's not about templates, but about logic)?
I'm just learning janga in practice, implementing a fairly large project, and after a month of writing I came to the conclusion that my approach is not at all optimal and prevents me from sticking to KISS and DRY, so please share your experience.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mark, 2010-11-07
@printf

In a good way, an application in django is a pure Unixway: it does one thing, does it well, has some external API for interacting with other modules. Usually, even in a small project, there are about a dozen applications. The advantages of this approach are that it is much easier to test, reuse the code, and you can relatively painlessly change the implementation of the module without disrupting the operation of the entire site.
Antipattern - monolithic applications (usually literally one or two). They, among other things, are harder to maintain, since the code performs many tasks that are not directly related (the functions responsible for generating RSS and changing the user's avatar are nearby - nothing can be done in such a file without half a liter and ctrl-F). This is especially true when a new developer is added to the team.
Application interaction is a much broader topic, it’s not so easy to cover it in two sentences, as it seems to me.

K
Konstantin Kitmanov, 2010-11-07
@k12th

I don't have much experience with Django, but it seems that this is exactly the method of fragmentation that is used - separate applications for each task.
And as for interaction - that's what Python has a very flexible system of imports for, isn't it?

E
Eugene, 2010-11-07
@immaculate

I have a large and old Django application. A balance is used between these two approaches: most of the functionality in one large application is broken into packages by modules, such as:
- big_app
- models
- profile.py
- content.py
- events.py
- forum.py
- views
- forum.py
- event.py
Part of it is moved to separate applications, I don’t understand why, because they still cannot be reused, since they are too dependent on the specifics of the application and use imports from the main application. But I didn't create this structure. I would probably instead add modules to an existing large application, and take out only code that can be reused in separate applications (we don’t have much of this, but we have).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question