A small educational Django project created while following a Udemy course (https://www.udemy.com/course/python-3-do-zero-ao-avancado). This repository contains a simple contact-list app used to practice core Django concepts: project layout, a contact app, templates, and static file handling.
- Project overview
- Prerequisites
- Setup (Windows / PowerShell)
- Common commands
- Notes about
db.sqlite3and.gitignore - Static files
- Development tips & troubleshooting
- Attribution
This is a compact learning project that includes:
- Django project folder:
project(settings, WSGI/ASGI) - One app:
contact - Templates under
base_templates/andcontact/templates/contact/ - Static assets in
base_static/ - Local SQLite database (
db.sqlite3) for easy development
The goal is to practice Django project structure, simple views, templates and static file management.
- Windows (PowerShell recommended)
- Python 3.11+ (this workspace uses Python 3.13)
- Git (optional)
The project assumes a virtual environment (venv/) that is not committed. If you don't have one, create it as shown below.
Open PowerShell in the project root (where manage.py is located) and run:
# Create and activate virtual environment (if needed)
python -m venv venv
& .\venv\Scripts\Activate.ps1
# Upgrade pip and install dependencies
python -m pip install --upgrade pip
pip install -r requirements.txt
# Apply database migrations
python manage.py migrate
# (Optional) Collect static files for production/WhiteNoise
python manage.py collectstatic --noinput
# Run development server
python manage.py runserverIf you prefer not to activate the venv, call the venv Python directly (example):
& "E:/Users/Fernando/Ambiente de Trabalho/Projetos/contact-list/venv/Scripts/python.exe" "E:/Users/Fernando/Ambiente de Trabalho/Projetos/contact-list/manage.py" runserverIf PowerShell blocks script execution when activating the venv, run (once) to allow local scripts:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser- Create an app:
python manage.py startapp <appname> - Make migrations:
python manage.py makemigrations - Apply migrations:
python manage.py migrate - Create superuser:
python manage.py createsuperuser - Run tests:
python manage.py test - Collect static files:
python manage.py collectstatic
- By convention, local database files (like
db.sqlite3) should not be versioned. This repository already containsdb.sqlite3in.gitignore. - If
db.sqlite3was already committed in the past, remove it from version control while keeping it locally:
git rm --cached db.sqlite3
git commit -m "Stop tracking db.sqlite3 and ensure it's in .gitignore"This removes the file from the Git index but keeps it on disk.
- Static assets (CSS, JS, images) live in
base_static/and appstatic/folders when present. - In development,
runserverserves static files automatically. - For production, run
python manage.py collectstaticand serve the collectedSTATIC_ROOTusing your web server (Nginx/Apache) or use WhiteNoise for simple deployments.
- Keep
DEBUG = Trueduring development andDEBUG = Falsein production. - If you encounter errors importing settings (for example a TypeError about type annotations), check any local settings files such as
project/local_settings.pyfor invalid assignments. An example of a problematic line is:
# invalid: can raise TypeError in some Python/Django versions
ALLOWED_HOSTS = list[str] = []It should use a type annotation or a plain assignment, for example:
# correct (annotation)
ALLOWED_HOSTS: list[str] = []
# or without annotation
ALLOWED_HOSTS = []- When
manage.py runserverfails, runpython manage.py checkfirst to get clearer configuration errors.
This project is for learning purposes only and was created while following a Udemy course used by the repository author.
Course referenced by the original repository: "Python 3: From Zero to Advanced" (Udemy).