Best Practice
The best apps do one thing and do it thing very well. If you have a major functionality or feature in your project (e.g. company products, shopping cart, etc.), you want to have it in its own self-contained app.
|___ src
|___ newsletter App folder
|___ __init__.py Registers parent folder as python file
|___ admin.py (new) Registers the app into the Django admin
|___ models.py (new) Processing and storing data into the DB
|___ tests.py (new)
|___ views.py App views
|___ home
1. Start New App
python manage.py startapp newsletter
This creates an app called "newsletter". Which means it creates a new folder called "newsletter" right under the "src" folder, and also creates the default python files for the app.
2. View
a. Place the function-based view code in newsletter/views.py
b. Use newsletter.views.home as the url pattern for the homepage in urls.py
c. Delete project's views.py file, we don't need it anymore for now.
Note:
We did the steps above basically because if the app you’re creating runs the homepage, then the view of the homepage should be handled by the views.py of the app itself.
3. Model
The actual app code in models.py
4. [settings.py]: Add model to INSTALLED_APPS: newletter
5. Database Migration
python manage.py makemigrations
python manage.py migrate