DEV Community

Cover image for Headless e-commerce framework for Django
Dino Perovic
Dino Perovic

Posted on

Headless e-commerce framework for Django

Whilst moving to the headless way of building the web I encountered the dilema — which solution to use to build e-commerce stores in Django?

I wanted a simple yet flexible system that focuses on the headless RESTful approach and while there are many solutions in the wild, each had me reading through the docs and code for hours trying to figure out where to start, how to extend, how to integrate with existent projects, etc.

Don't get me wrong, there are some excellent fully-featured solutions, but none of them were simple...at least not for me :)

Creating my own

In comes Salesman. I've created a small framework for building headless e-commerce. The idea was to make it as simple as possible for a beginner Django developer to pick up and get started, but also allow for advanced features to be added progressively.

The one and only requirement for this project is Django REST Framework.

Features

  • API endpoints for Basket, Checkout and Order
  • Support for as many Product types needed using generic relations
  • Pluggable Modifier system for basket processing
  • Payment methods interface to support any gateway necessary
  • Customizable Order model
  • Wagtail and Django admin implementation

Try it!

Salesman uses Poetry for virtualenv and dependency management so you should install it first.

Clone the repo

git clone https://github.com/dinoperovic/django-salesman.git
Enter fullscreen mode Exit fullscreen mode

Run the example

cd django-salesman/
poetry install -E example
poetry run example/manage.py migrate
poetry run example/manage.py create_dummy_products
poetry run example/manage.py createsuperuser
poetry run example/manage.py runserver
Enter fullscreen mode Exit fullscreen mode

Done! You can now:

  • Navigate to /api/ and start adding products to the basket and purchase items using The Browsable API.
  • View orders in both the regular Django admin (/admin/) or Wagtail cms (/cms/).

You can find the full documentation on Read the Docs.


What are your experiences with building e-commerce in Django?

Top comments (2)

Collapse
 
jjokah profile image
John Johnson Okah

That's simple and interesting.
I'm currently working with saleor ecommerce platform which is also headless but uses graphql.

Collapse
 
dinoperovic profile image
Dino Perovic

Yes Saelor is really good and mature. My issue with it was that it’s bulky and that it has it’s own dashboard + qraphql is a little more complex to use. I wanted salesman to be light (with no requirements) and compatible with the deafult Django admin and Wagtail aswell. This makes it easier to integrate with existent projects and for beginner devs to get started. I have plans to include a graphql option for salesman in the future, along with some other useful functions such as the discount module etc.