'integrating clean architecture with ORM

I'm trying to develop a monolithic Django application with Uncle Bob's clean architecture. The problem is I don't want to miss the powerful abilities of Django ORM but this will make a confusion at the same time. The ORM will handle the repository and data layer of application but at the same time makes problem in DTO because I don't want to transfer objects of type Django model.

Should I create a port to convert Django model objects into plain old Python objects? I think Django is not much suitable for integrating with clean architecture. I mean for a monolithic large scale application Django will have many down sides.



Solution 1:[1]

When you talk about Clean architecture, are you talking about hexagonal architecture ? If yes, your question is not only related to Django but to all languages.

The fundamental principle about the domain is that it should not have any dependencies. Given this principle, if a DTO is used by the ORM, it is very likely that you will have to do the mapping ORM Entities <-> Domain Model

Whatever the framework, and therefore the ORM that you use, it must not be imported into the domain which must remain agnostic in relation to everything and must therefore be coded in plain old language objects.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1