Reputation: 91650
I have a ton of models. I mean a ton. Would it be possible to reorganize these models into a nicer format using a new Python package?
IE: Current -
myproject/
web/
models.py
IE: New -
myproject/
web/
models/
__init__.py
events.py
registrations.py
lessons.py
...and simply import them all in my __init__.py
file? I'm kind of new to Python packages, will this essentially act the same as having a single models.py
file?
Upvotes: 4
Views: 92
Reputation: 66980
Yes. It's a bit tedious: you will want to revise which imports to keep in each file, etc., but it's definitely possible.
You can also do it piecemeal, by renaming models.py
to models/__init__.py
(which shouldn't have any effect at all), and then moving stuff out one module at a time.
Upvotes: 2