If you have several social media accounts, such as Google, Twitter, Facebook, and GitHub, and would prefer to use one of these accounts to log into websites that support third-party logins, you should read this article. The ability to seamlessly log in is thanks to OAuth2, a secure open protocol for authorization and access to protected third-party account data.
The OAuth2 protocol comes with various flows to handle different types of applications:
This article focuses on a Django web application that integrates with GitHub as the third-party OAuth2 provider.
Several Django extensions…
I recently attempted to deploy my Django projects on Amazon Lightsail and took notes for myself on the issues that came up for me. For starters, the AWS documentation for deploying a plain Django app without any database can be found here.
On the AWS console, we will find many Bitnami applications to choose from, including Django.
It’s common in most websites to allow visitors to interact with them through an HTML Form. To distinguish a human visitor from a machine or bot, a captcha challenge is typically included in the form as well. Some of these forms facilitate communication between a visitor and the website. Submitting one of these forms usually trigger an email to be sent to a specific address. Django provides an easy-to-use
send_mail() API to send data over the
SMTP protocol. In this article, I'm going to show how to create an HTML Form using Django's
FormView class with Simple Captcha and the…
Django provides a simple-to-code solution to edit your model in an HTML form if you use its class-based generic editing view such as
UpdateView. You can see a sample implementation of this in my article, Editing A Single Model Instance with UpdateView. However, in the real world, a complex application may want to support more than one HTML form on a webpage. Take for instance, a complicated job application that normally asks a lot of questions from various sources on a single page. I have seen webpages that have multiple save buttons corresponding to different sections on the page. Beneath…
In my last article, Leveraging OO in Models and Views, I described how we can maximize object-oriented programming techniques in implementing custom behavior in our Django models to hide model-specific QuerySet API and to take advantage of Django’s class-based generic views, such as
DetailView to reuse code and minimize development time.
Recall that in Django’s MTV (Model-Template-View) architecture, the model is the central component encapsulating data and behavior, the view defines which data from the model will be presented to the user and the template takes over how the data from the view will be presented in HTML. A typical…
There are many HTTP status codes that can be returned from a web server; one of them is the infamous
404 Not found error code. This error is raised when a particular page cannot be located on the website. Django handles the
Http404 exception by displaying a default error page for our application.
If we set the option
DEBUG=True in our project's settings.py file, we will see something like this:
In my previous article on Model Relationships, I described how Django implements one-to-one, one-to-many and many-to-many model relationships using the
ManyToManyField. Today I'm going to document how to leverage the power of object-oriented programming when writing Django models and views.
In a Django app that plans an employee’s tasks and meetings, much like a calendar app, we would like to be able to:
I’m going to highlight…
This article assumes a readership who is familiar with Python, Django and database schema design. Django explains its architecture as following an MTV (Model-Template-View) paradigm where model is the central component that encapsulates data and behavior for a web application, view is the mechanism that defines what data is to be presented to the user and template dictates how data will be presented to the user via HTML.