Software engineering facts, information, and skills categorized as Django
get_absolute_url in Django? When and why to use it?
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.
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
sitemaps.py. In the
sitemaps.py, we have to create a class by inheriting the class
django.contrib.sitemaps. In this class we can define our properties for entries in the sitemap.
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.
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.
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.
In django, the NULL valuein the database field is tested with field lookup
isnull It takes either
False, which correspond to SQL queries of
IS NULL and
IS NOT NULL, respectively.
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().