There are no problems with having multiple files containing views and models.
In fact, all you need is a views module and module models . In python, a module is either a file ending with .py or a folder containing the __init__.py file.
An application might look something like this:
app_folder - views | - __init__.py | - some_view.py | - some_other_view.py - models | - __init__.py | - some_model.py | - some_other_model.py
models/__init__.py should look something like the one shown below (for submodules that need to be looked at django in general).
from some_model import SomeModel from some_other_model import SomeOtherModel
The only difference from the general approach is to have the app_label defined in the models:
class SomeModel(models.Model): class Meta: app_label = 'app_folder'
View the related doc entry.
Update:
The docs version says that you will not need to define app_label in this case, starting from version 1.7.
Afterword:
In fact, if you need to do this, this usually means that your application is too large and you should split it up into several applications. Most people who come to django are afraid to have many small applications. The more third-party applications you read, the more you realize that the application should solve one and only one problem. In your example, the app milestones seems completely legal.
Krzysztof Szularz
source share