A Django news platform where journalists write articles, editors approve and publish them on behalf of a publishing house, and readers subscribe to publishers or journalists to read the articles they care about. The project also exposes a small REST API (Django REST Framework) for approved articles.
- Python / Django 6.0
- Django REST Framework for the API
- MariaDB / MySQL as the database (via
mysqlclient) - python-dotenv for environment configuration
See requirements.txt for the full pinned list.
M06T08 – Capstone Project – News Application/
├── README.md ← you are here
└── news_site/ ← Django project root (run all commands from here)
├── manage.py
├── requirements.txt
├── news_site/ ← settings, root URLs, WSGI
└── news/ ← the news app (models, views, urls, tests, API)
Run every command below from the
news_site/directory (the folder that containsmanage.py).
cd news_site
python -m venv venv
venv\Scripts\activate # Windows (PowerShell)
# source venv/bin/activate # macOS / Linuxpip install -r requirements.txtThe project uses MariaDB / MySQL. Create a database, then add a .env file
next to manage.py with your credentials:
DB_NAME=news_db
DB_USER=news_user
DB_PASSWORD=your_password
The database settings are read from these variables in
news_site/settings.py. The host is
localhost and the port is 3306.
Note for running tests: Django creates a throwaway test database, so the
DB_USERyou configure needsCREATEandDROPprivileges ormanage.py testwill fail during setup.
python manage.py migratepython manage.py runserverThen open http://127.0.0.1:8000/ in your browser.
Email (password resets, newsletter sends) uses Django's console backend in development, meaning messages are printed to the terminal running the server - no real mail account is required.
Anyone can sign up straight from the login page - every role has its own "Sign Up As…" button, so no command-line or admin setup is needed to get started. A publisher only needs to exist before an editor can join it, so the natural order is to register a publisher first.
A publisher (publishing house) now signs up directly via Sign Up As A Publisher on the login page - no admin involvement required. They pick a title, description, username and password, are logged straight in, and land on the publisher home page. Removing publishers and editors is handled by an admin from the admin home page (see Admins below).
Once at least one publisher exists, an editor can register via Sign Up As A Editor, choosing the publishing house they belong to. Editors review and approve the articles written under their publisher.
A journalist registers via Sign Up As A Journalist and can write articles. New articles start out unapproved if published by a publishing house. Journalists can group articles together into newsletters.
An article written by a journalist must be approved by an editor before it is published. Editors use their approvals dashboard to review and approve (or reject) articles for their publishing house.
A reader registers via Sign Up As A Reader, subscribes to publishers and/or journalists, and can then read the approved/published articles from those subscriptions.
Approved-article endpoints are available under /api/ (see
news/urls.py for the full list), including:
| Endpoint | Purpose |
|---|---|
GET /api/articles/ |
List approved articles |
GET /api/articles/<id>/ |
Retrieve a single article |
POST /api/articles/create/ |
Create an article |
GET /api/articles/subscribed/ |
Articles from your subscriptions |
GET /api/approved/ |
Approved-article log |
The API uses HTTP Basic authentication and DRF's browsable API renderer, so you can explore it in the browser or with a tool like Postman.
Automated tests for the REST API and the role-based logic live in
news/tests.py. From the news_site/ directory:
# Run the full test suite for the news app
python manage.py test news
# Run with more detail
python manage.py test news --verbosity 2As noted above, the test runner builds a temporary database, so the DB_USER
in your .env must have CREATE and DROP privileges.
The project ships with a Dockerfile and docker-compose.yml that run the
Django app and a MariaDB database together in containers. Run all commands
from the news_site/ directory (the folder containing docker-compose.yml).
As with the local setup, configuration is read from a .env file, which is
not committed to the repository for security. The Docker setup needs a few
extra variables compared with the local one. Create a .env file next to
docker-compose.yml with the following:
DB_NAME=news_db
DB_USER=news_user
DB_PASSWORD=your_password
DB_ROOT_PASSWORD=your_root_password
DB_HOST=db
ALLOWED_HOSTS=localhost,127.0.0.1
Important:
DB_HOSTmust be set todb(the name of the database service indocker-compose.yml) so the app container can reach the database over the Docker network. For the local (non-Docker) setup,DB_HOSTislocalhostinstead.DB_ROOT_PASSWORDis used by MariaDB to initialise the server.
docker-compose up --buildThis builds the image and starts both the web and db services. Once running,
the app is available at http://localhost:8000/.
First-run note: on the very first start, the database needs a few seconds to initialise. If the
webcontainer reports a database connection error whiledbis still starting up, simply restart the web service once the database is ready:docker-compose restart web
If you are running the app somewhere other than localhost (for example, on a
remote machine or an online playground), add that hostname to ALLOWED_HOSTS
in your .env file before starting, e.g.:
ALLOWED_HOSTS=localhost,127.0.0.1,your-host-name.example.com
docker-compose down







