A RESTful API for an online shopping platform, built with Django and Django REST Framework.
This is my first Django project, developed while following Mosh Hamedani’s Django Course.
- ⚙️ Backend: Django
- User authentication (signup, login, logout)
- Create, view, update and delete products as admin
- Create, view ,update carts as customer
- Add reviews for products
- Test for CRUD for important models and test access level
- Admin pannel
- Tagging items
The platform is built on a relational database schema designed to handle products, customers, carts, orders, and user interactions.
- Customer – Represents platform users. A
Customerprofile is automatically created when a new user registers (via Django signals). - Product – Represents items available for purchase.
- Collection – Groups products into categories or collections.
- Review – Customer feedback and comments on products.
- Cart – A shopping cart that holds products before checkout.
- CartItem – Specific items inside a cart, including quantity.
- Order – Customer orders created at checkout.
- OrderItem – Items included in a specific order.
- Address – Stores customer shipping/billing addresses.
- Promotion – Discounts or promotional offers applied to products.
- Tag – Used to categorize and organize products.
- TaggedItem – Relationship table linking tags to products.
- LikedItem – Tracks products liked by customers.
- 🛒 Provide a platform for selling products online.
- 💬 Allow customers to leave reviews and comments on products.
- 🛍️ Support shopping carts and order management.
- 👤 Manage customer profiles and addresses.
- 🏷️ Organize products with collections, tags, and promotions.
- ❤️ Enable users to like and save products for later.
- 🔒 Implement authentication and role-based access for security.
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /auth/users |
Register a new user | No |
| POST | /auth/jwt/create |
Login (returns JWT token) | No |
| GET | /api/users/me |
Get current user details | Yes |
Example Registration (POST /auth/users):
{
"username": "Ali",
"email": "ali@gmail.com",
"password": "Ali_1124",
"first_name": "ali",
"last_name": "Naghinejad"
}| Method | Endpoint | Description | Auth Required | Admin Required |
|---|---|---|---|---|
| GET | /store/products |
View products | No | - |
| POST | /store/products |
Add products | - | Yes |
| GET | /store/products/:id |
Get Products detail | No | - |
| PUT | /store/products/:id |
Update Products detail | - | Yes |
| DELETE | /store/products/:id |
Get Products detail | - | Yes |
| GET | /store/products/?(filter-field) |
Filter Product | No | - |
| GET | /store/products/?page= |
Paggination | No | - |
| GET | /store/products/:id/reviews |
View Reviews | No | - |
| POST | /store/products/:id/reviews |
Add Reviews | No | - |
Example Request (POST):
{
"description": "",
"title": "Banana",
"price": 100.00,
"inventory": 1,
"collection": 1
}| Method | Endpoint | Description | Auth Required | Admin Required |
|---|---|---|---|---|
| GET | /store/collections |
View Collections | No | - |
| POST | /store/collections |
Add Collections | - | Yes |
| GET | /store/collections/:id |
Get Collections detail | No | - |
| PUT | /store/collections/:id |
Update Collections detail | - | Yes |
| DELETE | /store/collections/:id |
Get Collections detail | - | Yes |
Example Request (POST):
{
"title": "Toy"
}| Method | Endpoint | Description | Auth Required | Admin Required |
|---|---|---|---|---|
| POST | /store/carts |
Create cart id | No | - |
| GET | /store/carts/:id |
Get cart items | No | - |
| DELETE | /store/carts/:id |
delete cart | No | - |
| GET | /store/carts/:id/items |
Get cart items | No | - |
| POST | /store/carts/:id/items |
Add items to cart | No | - |
| GET | /store/carts/:id/items/:id |
get specific item | No | - |
| DELETE | /store/carts/:id/items/:id |
delete item from cart | No | - |
Example Request (POST):
{
"product_id": 648,
"quantity": 2
}| Method | Endpoint | Description | Auth Required | Admin Required |
|---|---|---|---|---|
| GET | /store/customers |
View Customers | - | Yes |
| GET | /store/customers/me |
View User Customer | Yes | - |
| PUT | /store/customers/me |
Update Customers Data | Yes | - |
Example Request (POST):
{
"user_id": 4,
"phone": "0915*******",
"birth_date": null,
"membership": "G"
}| Method | Endpoint | Description | Auth Required | Admin Required |
|---|---|---|---|---|
| GET | /store/orders |
View orders for user | Yes | - |
| POST | /store/orders |
Create order by cart id | Yes | - |
| POST | /store/orders |
Create order by cart id | Yes | - |
| GET | /store/orders/:id |
View orders detail | Yes | - |
Example Request (POST):
{
"cart_id": "6233e2a4-bae6-44fd-a001-bc03a26667c8",
}| Method | Endpoint | Description | Auth Required | Admin Required |
|---|---|---|---|---|
| GET | /tag/tags |
View tags for products | No | - |
| POST | /tag/tags |
Create tags | - | Yes |
| GET | /tag/tags/:id |
View specific tags for | No | - |
| DELETE | /tag/tag/:id |
delete tags | - | Yes |
| PATCH | /tag/tag/:id |
Update tags title | - | Yes |
| GET | /tag/tags/:id/items |
View products in tag | No | - |
| POST | /tag/tags/:id/items |
Add Product to tags | - | Yes |
| DELETE | /tag/tag/:id/items/:id |
delete item from tag | - | Yes |
Example Request (POST):
{
"title": "Lovely"
}Follow these steps to set up and run the project locally:
git clone https://github.com/Mancity1383/Django-Store-Project.git
cd Django-Store-Project2.Create and activate a virtual environment
python -m venv venv
source /venv/bin/activate
pip install pipenv
pipenv shell3.Install required libraries if not working
pipenv install django
pipenv install django-debug-toolbar
pipenv install mysqlclient
pipenv install djangorestframework
pipenv install drf-nested-routers
pipenv install djoser
pipenv install djangorestframework-simplejwt
pipenv install redis
pipenv install celery
pipenv install flower
pipenv install pytest
pipenv install pytest-djang
pipenv install model-bakery4.Configure the database (MySQL)
#Change this part
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': config('DB_NAME'),
'USER': config('DB_USER'),
'PASSWORD': config('DB_PASSWORD'),
'HOST': config('DB_HOST', default='localhost'),
}
}5.Apply migrations
After that run this:
python manage.py makemigrations 6.Run server
python manage.py runserver