Part 2. Data Import

Image for post
Image for post
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 two sections: Import the data through the admin panel and build a simple UI for rendering as a simple user. …


Image for post
Image for post
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 comes to their classification in directories for example. …


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

Image for post
Image for post
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 fact, the xerographic technique used in most laser printers was invented by Chester Carlson which finally led the way to the first commercial automatic copier known as the Xerox 914. Over the years, Xerox Corp through PARC (Palo Alto Research Center) was home of many great innovations such as the Ethernet, the GUI etc … and they could have led the computer industry if they went on down that path, who knows ? For some reasons, they decided to fully focus on printers. They were so good at what they did that they turned this market into a monopoly and were even assign the etiquette of a company that only manufactured printers although they’re made other products as well. …


Image for post
Image for post
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, I’ve always overlooked get_or_created() because I found it so easy and straight to the task, I know a lot of us did and if you’re a newbie that never heard of that method, well you’re going to make the most out of it by the end of this piece. …


Better templating in Python

Image for post
Image for post
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 you to have the same data available across the entire application — by that, I mean across all templates of the application. What would you do in that case? …


Started with Django five years ago and still into it

Image for post
Image for post
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. …


Image for post
Image for post
Photo by Twitter: @jankolario on Unsplash

Understanding how important they are.

Let’s talk about Managers in Django because not a lot of people make use of them. The Django project getting started guide is a simple Poll application, and usually, people stick to practices and tricks they’ve acquired reading that guide.

A Manager is an interface through which database query operations are provided to Django models. At least one Manager exists for every model in a Django Application.

A very simple example of a Manager is objects when used in a query such as:

Model.objecst.all()

This is the default Manager added by Django but you can always use a name other than objects by renaming the Manager. …


Image for post
Image for post
Photo by Dayne Topkin on Unsplash

How Django can help reduce vulnerabilities.

In the process of building a Web application, security measures are not often taken into account by the web developers, especially if you’re working with security experts — we tend to let them deal with the global aspect of security which is not always ideal.

The Open Web Application Security Project (OWASP) is an online community that produces freely-available articles, documentation, tools, or security advises for web applications. …


Image for post
Image for post
Photo by Kelly Sikkema on Unsplash

Get the logic then everything else will be academic.

Developers often come across the need to implement a sort of membership system when selling a particular service on their website, we will do just that in a minute.

This article solely focuses on building or integrating a Membership/Subscription system in your existing Django application. Handling payments can be achieved using the Paypal or Stripe API but this aspect will be part of another article.

First thing first, we’ll start a new app called Membership.

./manage.py startapp membership

Next, we’ll go inside models.py and start adding the necessary models we’ll make use of. Most of the implementation will be done at the database level therefore, properly defining relationships between tables will determine the correctness of our membership application. …


Image for post
Image for post

At the end of the day, it’s all about KISS.

If you’re an experienced Django developer you’ve might have come across this practice. However, if you’re a beginner, being exposed to good practices will drastically decrease your learning curve.

Django URLs tip of the day : get_absolute_url(). the function name now happens to be a standard across the Django community but after all, it’s just another name so it’s up to you.

We’ll start by implementing a simple CRUD with Posts resource just so we can easily put things in perspective later on.

Model

Create a basic Post model with two properties a title and content. …

About

Farel Ellely

Tech Enthusiast | Back end Developer | Technical Writer | More content on farelellely.herokuapp.com

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