This is an e-commerce backend built using Django Rest Framework (DRF) with JWT authentication os used in development is fedora.
- Django
- Django Rest Framework (DRF)
- JWT Authentication
- Other dependencies (specified in requirements.txt)
The project is structured as follows:
e-commerce-assessment/
: Django project root directory.accounts/
: Auth model and logic.core/
: Django project settings directory.settings/
: Contains settings files.base.py
: Base settings.development.py
: Development settings.production.py
: Production settings.
static-files/
: Static files directory.templates/
: HTML templates directory.media/
: Media files directory (e.g., user-uploaded images).manage.py
: Django project management script.
-
Clone the repository:
git clone https://github.com/mwicwiri-bonface/e-commerce-assessment.git
-
Navigate to the project directory:
cd e-commerce-assessment
-
Install dependencies:
pip install -r requirements.txt
-
Update the .env file:
-
Create a new
.env
file in the project root directory. -
Add the following environment variables:
DEBUG=True SECRET_KEY=your-secret-key
Replace
your-secret-key
with your actual secret key.
-
-
Apply migrations:
python manage.py migrate
-
Create a superuser (admin) account:
python manage.py createsuperuser
-
Start the development server:
python manage.py runserver
-
Access the website at
http://127.0.0.1:8000/
.
For deployment to production:
-
Update the .env file:
-
Modify the
.env
file to include PostgreSQL database configuration for production:DEBUG=False SECRET_KEY=your-secret-key POSTGRES_DB_NAME=db_name POSTGRES_DB_USER=postgres POSTGRES_DB_PASSWORD=password POSTGRES_DB_HOST=127.0.0.1 POSTGRES_DB_PORT=5432
Replace
db_name
,postgres
,password
,127.0.0.1
, and5432
with the appropriate values for your PostgreSQL database.
-
-
Collect static files:
python manage.py collectstatic
-
Configure your production server (e.g., Gunicorn, Nginx).
-
Set up environment variables (e.g.,
SECRET_KEY
,POSTGRES_DB_NAME
,POSTGRES_DB_USER
,POSTGRES_DB_PASSWORD
,POSTGRES_DB_HOST
,POSTGRES_DB_PORT
). -
Deploy your application to your chosen hosting provider (e.g., Heroku, AWS, DigitalOcean).
-
To use the end points you'll need to get an api key from admin dashboard
-
To get API key for Hosted endpoints [https://ecomapis.pythonanywhere.com/admin/rest_framework_api_key/apikey/], Username: admin, Password: Leo@2024$
This project is licensed under the MIT License.