May 2018
Beginner to intermediate
282 pages
7h 58m
English
Like most components of Django, a large models.py file can be split up into multiple files within a package. A package is implemented as a directory, which can contain multiple files, one of which must be a specially named file called __init__.py. This file can be empty, but should exist.
All definitions that can be exposed at package level must be defined in __init__.py with global scope. For example, if we split models.py into individual classes, in corresponding files inside the models subdirectory such as postable.py, post.py, and comment.py, then the directory structure would look as follows:
models/├── comment.py├── __init__.py├── postable.py└── post.py
To ensure that all the models are imported ...
Read now
Unlock full access