The project is an online store website with the ability to place orders and save the results in a database. The project was implemented using the Django framework.
Python 3.8 and Django 3.2 were used as a basis. PostgreSQL was chosen as the database. Bootstrap and django templates were used to render frontend. Project version control was carried out using Git.
Before you start setting up the project, you need to install
Python 3 and PostgreSQL. In postgreSQL you also need to create a database called shop
.
- Cloning a repository with code
git clone https://github.com/akim-malyshchyk/django-marketplace.git
- Creating a virtual python environment (inside the repository folder)
python -m venv venv
- Activation of virtual environment (Linux)
source venv/bin/activate
- Install the necessary project dependencies
pip install -r requirements.txt
- Applying database migrations (creating tables)
python manage.py migrate
- Filling the database with test data
python manage.py create_default_data
As a result of executing the command, the superuser admin
with the password pass1234
will be created,
as well as goods for the store.
- Launch the project on your local machine
python manage.py runserver localhost:8000
After completing the procedures, access to the website should appear in the browser at https://localhost:8000
.
- Selecting products and adding them to cart
- Select the quantity of products
- Calculation of order cost taking into account the number of goods
- Admin panel with the ability to edit data about products, categories, orders and users
- User login and registration
In addition to the standard Django tables, 5 more were created. The tables and relationships between them are shown in the screenshot below.
The project consists of two applications: accounts
and shop
. Each of them represents a folder in which
are located:
- models for the database (
models.py
) - logic for working with user requests (
views.py
) - forms (
forms.py
) - list of used urls (
urls.py
) templates
folder with html page templates- some other supporting files
html templates were written using Django Template Language, which allows you to dynamically change templates in depending on the data. Layout and styling were implemented using Bootstrap. To avoid code duplication in some Template inheritance was used in some places.
The src
folder contains a file with the main project settings (settings.py
), and others necessary for launching
website files.
The manage.py
script is responsible for launching the project; the project's dependencies are stored in the requirements.txt
file.
All product categories are displayed on the main page of the store
Using the View goods
button you can open any category. Here you can add items to your cart,
indicating the required quantity
After selecting the required products, you can go to the ordering page by clicking on the Cart
button
After filling out and submitting the form, an order will be generated in the database. It can be seen by the administrator on the Admin page
.
The admin panel was implemented using Django's built-in tools
On the admin panel you can edit information about products and categories, as well as view generated orders