1👍
✅
Views are just python modules, you can do whatever you want, for instance you can change their names to whatever.py
as long as your imports
are correct 🙂
And as suggested: find more info here Django: split views.py in several files 🙂
4👍
Yes, you can. A modular way of splitting would be to create a package – views/
- views/
- first.py
- second.py
- __init__.py
and in your __init.py__
add the following:
from .first import *
from .second import *
This way, all your views would be available for urls.py
.
- [Django]-How to insert multiple images into a blog post not File field upload (Django blog)
- [Django]-Dynamic FormWizard
0👍
You can totally do that, it is only a convention to use views.py
.
Now, the question is: do you really need to create a new file to put your views inside ? Shouldn’t these regrouped in a new application ?
Think of an other person reviewing your code: would the reason of the separation be crystal clear to him ?
Source:stackexchange.com