PageView

Stories about Python, Django and Web Development

Django Tips #19 Protecting Sensitive Information

Django Tips #19 Protecting Sensitive Information

The internet is a wild land. Security must be priority one when deploying a web application on the internet. The Django framework does an amazing job providing reliable and secure APIs. But none of that matters if we don’t use them properly.

Read more



How to Handle GitHub Webhooks Using Django

How to Handle GitHub Webhooks Using Django
Webhooks are a convenient way to notify external services when a certain event occur. GitHub provides an easy way to create Webhooks for the git repositories. You can pick the events such as push, pull requests, and only be notified when they occur. It can be used to integrate external applications with GitHub, perform Continuous Integration tasks or automate deployments. In this tutorial I will show you how to securely handle those notifications in a Django application.

Read more



How to Add Social Login to Django

How to Add Social Login to Django
In this tutorial we will implement Facebook, Twitter and GitHub authentication using the social-auth-app-django library. They support several other services and the process should be somewhat similar. The social-auth-app-django library have several customization options, which sometimes makes it challenging to get started. So for this tutorial I will guide you through the mandatory steps where in the end you will have a fully functional social authentication.

Read more



Django Tips #18 Difference Between ugettext And ugettext_lazy

Django Tips #18 Difference Between ugettext And ugettext_lazy

The Django translation API provides several utility functions to help you translate your application. They are all available in the django.utils.translation module. For the most cases you will be using ugettext() and ugettext_lazy().

Read more



How to Deploy a Django Application to Digital Ocean

How to Deploy a Django Application to Digital Ocean

DigitalOcean is a Virtual Private Server (VPS) provider. In my opinion it’s a great service to get started. It’s cheap and very simple to setup. In this tutorial I will guide you through the steps I go to deploy a Django application using Ubuntu 16.04, Git, PostgreSQL, NGINX, Supervisor and Gunicorn.

Read more



How to Use Django's Generic Relations

How to Use Django's Generic Relations

You probably have already seen Django’s ContentTypes and wondered how to use it or what is it for anyway. Basically it’s a built in app that keeps track of models from the installed apps of your Django application. And one of the use cases of the ContentTypes is to create generic relationships between models. That’s what this post is about.

Read more



How to Use django-hosts Library

How to Use django-hosts Library

This is a very handy Django package that I’ve used in a couple of projects. Essentially django-hosts let you serve different parts of your application under different subdomains. For example, let’s say we have a Django application deployed on www.example.com. With this app you can serve an e-commerce under shop.example.com and the help center under help.example.com. And in the end, it’s just a single Django website.

Read more



List of Useful URL Patterns

List of Useful URL Patterns

The ability to create beautiful and meaningful urls is certainly something I love about the Django Framework. But truth is, it’s very hard to get it right. Honestly I always have to refer to the documentation or to past projects I’ve developed, just to grab the regex I need.

Read more



How to Use Python isort Library

How to Use Python isort Library

isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections. It’s very useful in Django projects, specially in views where we usually deal with a great amount of imports.

Read more



Django Tips #17 Using QuerySet Latest & Earliest Methods

Django Tips #17 Using QuerySet Latest & Earliest Methods

Similar to the QuerySet methods first and last, the API also offer the earliest and latest methods. They are convenience methods which can be used to enhance the readability of the code.

Read more