[Django]-Can I make a folder of forms and views and use an __init__.py file like models and test?

3👍

Just make a folder for your views and a folder for your forms wherever you want them to be and put an empty __init__.py file into each folder. The purpose of the __init__.py file is to tell python to treat the folder as a module. Then make your views.py file and your forms.py file in their respective directories and now you can do…

from myproject.path.to.views import MyView
from myproject.path.to.forms import MyForm

…as if it were any other module. Which it is.

👤jhrr

Leave a comment