Django shop cms - Python-Django E-commerce website


Small E-commerce website example. 

https://github.com/WirOem/django-shop-cms 

Create a folder for your project. Create a virtual environment (in that folder) and install Django

Open the folder in visual studio code.

Download a bootstrap template and save it in the same folder and extract it.

Activate the virtual environment.

Start the project and build the first app (core).

Open settings.py file and edit it in the following way.

Create the templates folder

Specify the app in the “INSTALLED APPS” section.

Open the following link in a browser 

Copy the following code

Paste the code in the settings.py file like this.

Create the “static folder”.

Copy the ‘index’ file to a new folder in the ‘templates’ folder.

Copy the folders in the ‘asset’ folder to the ‘static’ folder.

Add this piece of code to the ‘index’ folder.

Open the urls.py file in ‘ecom’ and add the following

Create a new urls.py file in the ‘core’ folder and add the following

Open the views.py file and write the following view.

Open the index.html file and change all the urls (locations) of the files according to jinja templates. The image below shows a part of it.

Create a new app (accounts). 

Create a superuser to login as the admin

Login as admin with the previous credentials.

You are now logged in as the admin of the website.

Open models.py from core and type the following in order to create the database and tables.

Open admin.py from core and type the following.

Refresh the webpage. The customer model is created. We can now add customers to it.

Add a login and a register button. Open the index.html file and modify the code like this


Write the views for login, logout and register.

Write the urls for login, logout and register.

Create an ‘accounts’ folder in templates. Create a ‘login’ file and a ‘register’ file in the accounts folder. Put the following code in the files.


Modify the code in the index.html file

Write 3 views for register, login and logout

You can now easily register, login and logout.


Add categories and products.

Add products to the page without logging in as admin first. (Add an “add product” button)


Add description to the products

Add products to cart option

We only want the “Add Product” option for the Admin. Modify the code in the index.html file like this:

Models, views and html.file to make orders, add and remove to cart.

Models, views and html.file for checkout

Views and urls for paying.





Comments