Software engineering facts, information, and skills categorized as Django

What is @permalink and get_absolute_url in Django?

Varghese Chacko 1 year ago

What is @permalink and get_absolute_url in Django? When and why to use it?

Django Python

Configure Amazon S3 for Mezzanine - a Django Blog engine

Varghese Chacko 1 year ago

Amazon S3 is an efficient static file storage system for its services and relatively cheap. On the other hand Django is a nice web development framework that doesn't like to handle static files. Mezzanine is a popular blog engine  built in Django. Since Django doesn't like to handle static files on production systems, we always have to configure a web server like nginx or apache webserver to serve static files. On the other hand, its easy to host static files to Amazon S3. The S3 configuration for static files is easy, but saving user uploaded files for Django web app may raise some permission issues. Here is how we have configured the Django-S3-Mezzanine blog.

Create sitemap using Django sitemap framework

Varghese Chacko 1 year ago

The django sitemap framework is very flexible. We can use it to create sitemap for any item in thedatabase, along with custom configurations. The very basic step is to add django.contrib.sitemaps to the installed apps. Then it is better to have our own In the, we have to create a class by inheriting the class Sitemap from django.contrib.sitemaps. In this class we can define our properties for entries in the sitemap.

Create sitemap for static pages in Django application

Varghese Chacko 1 year ago

We have both static and dynamic pages in a Djangoapplication. How will we add static pages to stitemap? It is very siple. As first step, we have to include 'django.contrib.sitemaps' to the installed apps.

Create sitemap for Django application via sitemap framework's GenericSitema...

Varghese Chacko 1 year ago

Sitemaps are very critical for SEO. For a Django application, how can we add sitemap? The django applications has dynamic content and it is almost impossible to recreate a sitemap and upload to the site. The django sitemap framework is for our rescue.

Search database with regular expression in Django

Varghese Chacko 1 year ago

Regex and iregex are  the two field lookups that enable us to search database with regular expressions. regex is case-sensitive where as iregexis case-insensitive.

Django - check for null in database

Varghese Chacko 1 year ago


In django, the NULL valuein the database field is tested with field lookup isnull It takes either True or False, which correspond to SQL queries of IS NULL and IS NOT NULL, respectively.

Django field lookup - contains and icontains

Varghese Chacko 1 year ago

Field lookups are how we specify the conditions in the WHERE clause of an SQL. They are specified as keyword arguments for QuerySet methodslike filter(), exclude() and get().