I have just learned that splitting model classes into different files breaks many of django's built-in functionalities.
I am coming from a java background. There, it is not accepted as a good practice writing very long class files. But django's enforcement of single file for all model classes will probably cause programmer to write very long models.py files. This will make it difficult for programmer to see the organization of the whole domain model.
So why does django enforce single file to contain all domain classes?
I have found a solution proposal to this problem by googling. But I cannot be sure whether this will work properly. Do you suggest this solution?
Django web applications access and manage data through Python objects referred to as models. Models define the structure of stored data, including the field types and possibly also their maximum size, default values, selection list options, help text for documentation, label text for forms, etc.
Model.py is one of the most import concept of django framework. It allows us to completely define the database of our web applications allowing us to : Declare tables and fields of our database. Define all meta-data of our Database.
Django models simplify the tasks and organize tables into models. Generally, each model maps to a single database table. Each model is a Python class that subclasses django.
Single namespace: yes. Single module: no.
Your models have to be importable from namespace appname.models
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With