How to create a REST API with Django using the TDD approach — Part 2


Photo by Goh Rhy Yan on Unsplash

This is the second part of our small tutorial on how to build a very simple API in Django and djangorestframework through TDD. In the first part, we implemented our model then tested it against a few test cases and it worked.

In this part we will focus on the three endpoints we defined in the first part. Let’s start by theoretically define what we need to have functional API endpoints:

  • URLs

Photo by Goh Rhy Yan on Unsplash

TDD stands for Test Driven Development which is a software development process relying on software requirements being converted to test cases before software is fully developed. This is opposed to software being developed first and test cases created later. — Wikipedia

The large majority of independent software developers — that includes me — do not write tests for one reason or another. Whenever I was building a simple REST API or any application I reckoned spinning up Postman or the browser to test your endpoints was just enough for me to validate the functionalities.

After years of taking the same…

Photo by Kaleidico on Unsplash

Given the on going circumstances, Digital transformation has become the De facto resolution to almost every organizations around the world — regardless of their size.

We all know how tough of a job it is to plan, develop and deploy a digital project. It gets even more difficult when the company has to run on limited resources.

This piece highlights a few steps every solution analyst should know before taking on any digital transformation projects. It can be applied to literally any digital project implementation in the broader sense.

1 — Identify the need for business process improvements.

To identify the need for improvement, the customer has to answer…

Django and Tesseract in action

Photo by Mark Rasmuson on Unsplash

OCR basically stands for Optical Character Recognition/Reader.

“It is the electronic or mechanical conversion of images of typed, handwritten or printed text into machine-encoded text, whether from a scanned document, a photo of a document, a scene-photo or from subtitle text superimposed on an image and it is one of the applications of computer vision”. — Wikipedia

To make it simple, it is a technology that lets you convert whatever file that contains some text to be processed in it — whether a JPG or PDF format — into a machine-encoded text so you can edit, append or deduct whatever…

Part 2. Data Import

Photo by Jonas Leupe on Unsplash

This is the second part of how to generate barcodes using the Django Web framework.

This part will focus on importing a list of customer name from an excel or CSV sheet. By default, the generated barcode in Part 1 is in PNG format; we need to change that as well to a PDF format so they can be easily printable, this will be the subject of a third and final part.

Bear in mind that I’m not a great UI guy so, we will do just the minimum required for the display. We’re going to split this piece into…

Photo by Jonas Leupe on Unsplash

Currently working with an Enterprise Solutions that serves as a CPR (Capture Process Route) tool for increasing knowledge workers productivity by at least 50%, if your workflow includes storing digital documents in different locations day in and day out. It has some quite outstanding features under its belt and the one I am trying to use right now is batch scanning through barcodes.

What this feature does is, it scans a load of paper and automatically groups them based on their appropriate destination. Generally speaking, the process of going from paper to electronic documents is often cumbersome, especially when it…

Times of making old fashion boxes have come to an end.

Image credit: Logolynx

I remember my time in India, I didn’t have a personal printer so I had to go to an internet cafe in order to make prints or copies of a document. Somehow the expression we used was always “I need to make a xerox ”, though the printers used were Canon or HP branded.

It was only years later, after working with a Xerox Partner that I came to understand we were referring to the Xerox Corporation because they are in a sense the pioneer of modern printers. In…

Photo by Anthony Martino on Unsplash

Handling objects creation the easiest way possible.

It’s been quite some time that I play with Django, a couple of years to say the least and this is in my opinion one of the most overlooked methods by new Django developers.

Speaking of my own experience, I remember when I just started programming, my code had to be pretty thick and complex otherwise I wouldn’t be happy with it and I wrote a story on looking back at my 1st GitHub repo that is the perfect illustration of it.

Anyway, “ Revenons à nos moutons ”! As I was saying…

Better templating in Python

Photo by Vishnu R Nair on Unsplash.

Let’s talk about context processors and see how you can use them effectively in your Django projects.

“A context processor has a simple interface: it’s a Python function that takes one argument, an HttpRequest object, and returns a dictionary that gets added to the template context. Each context processor must return a dictionary.

Custom context processors can live anywhere in your codebase as long as they are pointed to by the context_processors argument of Engine.” — Django’s documentation

When working with multiple and separate views, you may load different data objects into different views, but sometimes the use case requires…

Started with Django five years ago and still into it

Photo by 𝓴𝓘𝓡𝓚 𝕝𝔸𝕀 on Unsplash

You probably have an idea of what that article will be made of by reading the title, and guess what? You are right my friend. …

Farel Ellely

Tech Enthusiast | Back end Developer | Technical Writer | More content on

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store