This E-Commerece Project gives general glimes of commerical shopping site where a user can make purchase of his/her requirements under different categories, can view thier purchase history and order status while they can also add products to their carts for later purchase.
- python version - 3.0, for as backend core language.
- Django version - 3.2, for web framework of python
- Djongo version - 1.3, for connecting to mongodb database.
- redis-server version - 6.0, for serving message caching.
- celery - 5.1, for queueing task.
- pillow - 8.3, for serving image file to python django.
Step By Step Installation Guide.
-
Create an virtual environment for project as virtual environments allows you to avoid installing python packages globally and run multiple instances of web applications on different versions of python and django, on a single machine. Here is a guide on how to install Virtualenv.
- Before we start, we need to create a virtualenv for our app, so open up your Command Prompt (for Windows) or Terminal (for Mac, Linux) and type the following:
virtualenv venv
- Before we start, we need to create a virtualenv for our app, so open up your Command Prompt (for Windows) or Terminal (for Mac, Linux) and type the following:
-
Clone the project.
git clone https://github.com/JaydeepJikadra/E-Commerce.git
-
Make sure you are in E-Commerce folder.
-
Install all dependencies into virtual environment.
pip install -r requirements.txt
-
Install mongodb for your system from here.
-
Create database in mongodb and you can update your database name and url in your settings file.
DATABASES = { 'default': { 'ENGINE': 'djongo', 'NAME': 'Database Name', 'HOST':'Your Database Url', } }
-
Create superuser by below command and enter your credential to access admin section.
python manage.py createsuperuser
-
After connecting to the database you can migrate by following commands.
python manage.py makemigrations python manage.py migrate
-
Run the development server from the terminal by below code.
python manage.py runserver
-
Now you are ready to use this project.
-
As first thing needed for deployment is Procfile file which consists of our wsgi and worker settings which is necessary for deploying our site.
web: gunicorn eshop.wsgi --log-file - worker: celery -A eshop.celery worker -B --loglevel=info
-
Next important step is for creating runtime.txt file with mentioning our language version.
python-3.8.10
-
Now by creating an .env file beside settings.py file and declare all the environment variables needed for our site.
-
For serving static files in django, we need to install whitenoise as django does not support serving static files in production, by default.
pip install whitenoise
-
We also need to add whitenoise to our middlewares into settings.py file for letting django to know about whitenoise.
MIDDLEWARE = [ ... 'whitenoise.middleware.WhiteNoiseMiddleware', ]
-
Now you can collect all the static files over folder in one folder by command.
django-admin collectstatic
-
Open up settings.py file and make the following changes, preferably at the bottom of the file.
STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
-
As project is meant to deploy on heroku we needed heroku cli,which you can download as per your system.
-
For unbntu 16+, run the following from your terminal:
sudo snap install --classic heroku
-
you can also check out the documentation heroku cli.
-
-
Login to heroku cli from terminal through your credientials.
-
Create an heroku app with unique name.
heroku create shopfreeapp
-
By creating app, you can add git remote location and can commit your stage level by -
git add . git commit -m "Initial commit"
-
After commiting you can push project to heroku by-
git push heroku master