E-commerce project backend API using Django Rest Framework
This is a Django backend project for an e-commerce application. It provides the API endpoints required for managing products, categories, user accounts, shopping carts, and orders and wishlist and paymment method stripe. The project is built using Django and Django Rest Framework.
To set up the development environment for this project, follow these steps:
- Python 3.9 or higher
- Django 3.2 or higher
- Virtualenv (optional but recommended)
- Clone the repository: `git clone git@github.com:MohammedFarhoud/e-commerce-django-backend.git'
- Navigate to the project directory:
cd your-project
- Create and activate a virtual environment (optional):
virtualenv env && source env/bin/activate
- Install the project dependencies:
pip install -r requirements.txt
- Create a
.env
file in the project root directory. - Configure the necessary environment variables in the
.env
file, such as database credentials and API keys.
- Run database migrations:
python manage.py migrate
- (Optional) Load initial data fixtures:
python manage.py loaddata initial_data.json
To run the Django project locally, follow these steps:
- Activate the virtual environment (if used):
source env/bin/activate
- Start the development server:
python manage.py runserver
- Open your web browser and visit:
http://localhost:8000/
To install the Stripe CLI on Debian and Ubuntu-based distributions:
-
Add Stripe CLI’s GPG key to the apt sources keyring: curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | sudo tee /usr/share/keyrings/stripe.gpg
-
Add CLI’s apt repository to the apt sources list: echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | sudo tee -a /etc/apt/sources.list.d/stripe.list
-
Update the package list: sudo apt update
-
Install the CLI: sudo apt install stripe
-
login in cli stripe login
-
Use the --forward-to flag to send all Stripe events in test mode to your local webhook endpoint. To disable HTTPS certificate verification, use the --skip-verify flag.
stripe listen --forward-to localhost:8000/api/webhook
The project structure follows the standard Django app structure:
manage.py
: The Django project management script.your_project/
: The project's main directory.settings.py
: Django project settings.urls.py
: URL configuration for the project.your_app/
: The main app directory.models.py
: Database models for the app.views.py
: Views and API endpoints for the app.serializers.py
: Serializers for converting models to JSON.tests.py
: Unit tests for the app.