Skip to content

Simple Django contact-list app — an educational project with a single app, templates, and SQLite.

Notifications You must be signed in to change notification settings

fernandosc14/contact-list

Repository files navigation

contact-list

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.

Table of Contents

  • Project overview
  • Prerequisites
  • Setup (Windows / PowerShell)
  • Common commands
  • Notes about db.sqlite3 and .gitignore
  • Static files
  • Development tips & troubleshooting
  • Attribution

Project overview

This is a compact learning project that includes:

  • Django project folder: project (settings, WSGI/ASGI)
  • One app: contact
  • Templates under base_templates/ and contact/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.

Prerequisites

  • 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.

Setup (Windows / PowerShell)

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 runserver

If 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" runserver

If PowerShell blocks script execution when activating the venv, run (once) to allow local scripts:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Common commands

  • 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

Notes about db.sqlite3 and .gitignore

  • By convention, local database files (like db.sqlite3) should not be versioned. This repository already contains db.sqlite3 in .gitignore.
  • If db.sqlite3 was 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 files

  • Static assets (CSS, JS, images) live in base_static/ and app static/ folders when present.
  • In development, runserver serves static files automatically.
  • For production, run python manage.py collectstatic and serve the collected STATIC_ROOT using your web server (Nginx/Apache) or use WhiteNoise for simple deployments.

Development tips & troubleshooting

  • Keep DEBUG = True during development and DEBUG = False in production.
  • If you encounter errors importing settings (for example a TypeError about type annotations), check any local settings files such as project/local_settings.py for 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 runserver fails, run python manage.py check first to get clearer configuration errors.

Attribution

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).

About

Simple Django contact-list app — an educational project with a single app, templates, and SQLite.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published