Django admin — Display time in the current timezone

I had a Django project where a cronjob will run at certain intervals and add an entry in the database if the task is executed successfully. My project used UTC as the default timezone. When I look at the execution time of the tasks in the Django-admin site all the execution times were in UTC. Although it […]

Read More
  • Posted by allwinraju
  • December 20, 2020
  • 0 Comments

Cookies in Django – Setting, retrieving and deleting cookies

HTTP is a stateless protocol so when a request is sent to the server, it does not know whether you are requesting the page for the first time or you are the same user who has visited this page many times before. This HTTP statelessness was a problem for ecommerce website developers because persistence among […]

Read More
  • Posted by allwinraju
  • December 19, 2020
  • 0 Comments

Python one-liners

This blog post contains some of the python one-liners which I have gathered from various sources. The link to the repository is given below. If you are interested you can also add your own one-liners if I have missed any. https://github.com/Allwin12/python-one-liners anagram binary to decimal convert string to lower case convert string to upper case […]

Read More
  • Posted by allwinraju
  • December 9, 2020
  • 0 Comments

Credit card number validation using Luhn’s algorithm in python

In this blog post, we shall how to validate a credit card number using Luhn’s algorithm. We shall also learn about Luhn’s algorithm where and how it is used. This blog post also contains a sample python code to validate the credit card number. Luhn’s algorithm The Luhn algorithm or Luhn formula, also known as the “modulus 10” […]

Read More
  • Posted by allwinraju
  • December 8, 2020
  • 0 Comments

XML response in Django using Django-rest-framework

In this article, we shall see how to return the response from our Django project in XML format instead of the traditional JSON response. We have to install a third-party package first in order to render XML response. REST Framework XML provides a simple informal XML format. It was previously included directly in the REST […]

Read More
  • Posted by allwinraju
  • October 30, 2020
  • 0 Comments

Top youtube channel for programmers

YouTube is great for the what and the why, but text is the best for the how. Keep that in mind. Some of the YouTube channels might be a bit obsolete. Nonetheless, the advice you’ll find will help you get into coding, land your first beginner programming job if you’re just starting out, or up […]

Read More
  • Posted by allwinraju
  • October 10, 2020
  • 0 Comments

Find if a string is empty in python

This blog post discusses which is the best method to find if a string is empty in python. We all would have known about the naive method. But let us see which one is the most effective and efficient method to find the empty string. In the naive method we would do something just like […]

Read More

Lesser-known methods in Django ORM

We all know Django provides ORM right out of the box thus preventing us from writing SQL queries. This mechanism has a lot of potentials. Most of us will be dealing only with the filter(), get(), all(), update() and delete() methods from the Django ORM. But Django ORM provides a lot of other options in […]

Read More

Django — Get browser and OS info from the HTTP requests

This blog post focuses on finding various information about the nature of the browser and os from which the HTTP requests are made. The following information can be obtained from the requests. If the device is a mobile/PC Browser name Browser version OS of the computer or mobile OS version Device name Let us get […]

Read More

Escape and unescape HTML using python

This blog post teaches you to escape and unescape HTML strings and files using a built-in module in python called “html”. This module has two methods escape() and unescape() which lets us do this operation. 1. Escape First, let us see how to escape HTML strings and files using the escape() method from the HTML module. What is escaping […]

Read More