A simple python backend service "News blog with nested comments".
Tested on Ubuntu 20.04 and
Python==3.8.10
Django==4.0.4
django_environ==0.8.1
django_mptt==0.13.4
environ==1.0
requests==2.27.1
pip==22.0.4
The system have API methods that provide:
-
✓ Adding an article.
-
✓ Adding a comment to an article.
-
✓ Adding a comment in response to another comment (any nesting is possible).
-
× Retrieve all comments on an article up to 3 levels of nesting.
✓ Retrieve all comments on an article up to 20 levels of nesting. -
✓ Retrieve all nested comments for a level 3 comment.
-
× A tree structure can be recreated from the comment API response.
✓ A tree structure is recreated from the comment API response. Via html, css, js.
Non-functional properties:
- ✓ Using Django ORM.
- ✓ Following the principles of REST.
- ✓ The number of queries to the database doesn't directly depend on the number of comments, nesting level.
- ✓ Solution in the form of a repository on Github.
- ✓ README.md, which shows how to build and run the project.
- ✓ Specify dependencies in requirements.txt.
- ✓ Using the latest versions of python and Django.
Additionally:
- × Using PostgreSQL.
- ✓ docker-compose to run api and database.
- × Swagger or other API documentation.
These instructions will get you a copy of the project up and running on your local machine. There are two ways to run a project.
- run without Docker
- run with Docker
Clone the repository
git clone https:github.com/Alexander671/test_news
Navigate into the test_news
directory
cd test_news/test_news
For correct work you need to create .env file in ~/PROJECT_DIR/test_news/test_news/.env with the following content:
nano .env
SECRET_KEY = <your_secret_key>
DEBUG = <True/False>
ALLOWED_HOSTS = <list_hosts>
Install, using pip
:
pip install -r requirements.txt
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py runserver
Clone the repository
git clone https:github.com/Alexander671/test_news
Navigate into the test_news
directory
cd test_news/test_news
For correct work you need to create .env file in ~/PROJECT_DIR/test_news/test_news/.env with the following content:
nano .env
SECRET_KEY = <your_secret_key>
DEBUG = <True/False>
ALLOWED_HOSTS = <list_hosts>
- Build the image
docker build .
- Сompiling the image with the team
docker-compose build
- Run container:
docker-compose up -d
Some edge-cases examples are available on the examples
folder.
- Alexander Matveev - Initial work - Alexander671