Yawd website


  1. Elorus - Online Invoicing & Billing Software

    Although this blog should serve as a programmer's place, I could not help but talk to you about Elorus eInvoicing & Cash Flow Management. Elorus is our new service developed entirely in Django and based on our yawd-admin open source application.
    Posted on February 19th, 2013 by Pantelis Petridis
  2. Web-font files not showing in Firefox

    I know it's been a while since my last post, but here's a quickie I came across today, one might find it useful:

    In a typical Django setup you might be serving your static & media files through concrete sub-domains. For example, our Elorus eInvoicing/cash flow application serves static files through static.elorus.com and the application itself runs on app.elorus.com. On our production server I noticed this strange behavior where all browsers worked as expected,...

    Posted on February 15th, 2013 by Pantelis Petridis
  3. Tuning the yawd-elfinder Django file manager performance

    The latest version of yawd-elfinder allows you to manage your remote files through the application and link them to your models using Django file storages. There exist several 3rd party storage applications (like django-storages, django-dropbox etc.) that enable connection to various remote systems. Amazon s3, ftp and sftp backends, even your dropbox public folder are just an example of what can be connected to yawd-elfinder.

    However, depending on the driver, remote connections may affect the performance of yawd-elfinder. For example the dropbox storage uses a restful API to perform its operations, meaning that an http request must be sent for any required information. Although yawd-elfinder instantiates each storage only once in an effort to avoid negotiations for subsequent elfinder requests, this is not enough. To improve performance in this case you can use two options that tune the caching behavior of yawd-elfinder.

    Posted on November 7th, 2012 by Pantelis Petridis
  4. The impact of Django page redirects to SEO - Fixing internationalized pattern URLs

    Django makes heavy use of page redirects to handle form submissions, manage multilingual content and accomplish many other tasks. While there's nothing wrong with that (in fact in most cases it is considered to be the best practice), careless use of page redirects might affect our website's page rank. To better understand the potential danger we should first see how redirect works and which tools does Django provide for redirecting to a new page. We will also examine & fix a case where Django does not use the optimal redirect type: the internationalized URL patterns.
    Posted on October 4th, 2012 by Pantelis Petridis
  5. Managing files with django - a yawd-elfinder tutorial

    File management with django and yawd-elfinderFile management with django and yawd-elfinder.

    I've always liked elFinder. It is a jQuery application that allows for managing files through a web page. elFinder is capable of uploading, moving, previewing and editing all kinds of files on the fly. In version 2 you can also resize, rotate and crop your images online, so it is a perfect solution for your django website's administration interface. To integrate elfinder with django we created a reusable django application, the yawd-elfinder. In this simple tutorial we will install yawd-elfinder and connect it to our models. For more control over your files, please advice the documentation.

    Posted on September 24th, 2012 by Pantelis Petridis
  6. SEO-friendly image names with sorl-thumbnail and Django

    When working with Django, I tend to use sorl-thumbnail more and more. It is a quick & easy way of generating image thumbnails for your application. As a matter of fact, I use it on almost every img tag on my templates to ensure that user-upload images will fit the page layout. But the URLs that the application generates are of the form http://media.example.com/cache/9f/0c/9f0c98435b16bcea2b9ead87.jpg. Except for being unpretty, such URLs are SEO deal-killers.

    Posted on August 20th, 2012 by Pantelis Petridis
  7. Fix IndexError/KeyError in sorl.thumbnail.engines.pil_engine._orientation with PIL

    PIL sometimes fails to read an image's exif header. Sorl-thumbnail v11.12 does not correctly handle all the exceptions that the PIL library can generate resulting in the error below:
    Posted on April 18th, 2012 by Pantelis Petridis
  8. Ajax Coin Slider: A jquery image slider with asynchronous image loading

    Ajax coin slider - screenshot from the yawd websiteFigure 1. Ajax coin slider - screenshot from the yawd website

    While working on my latest project, I was in need for a jquery slider capable of loading images asynchronously. When you run a big website with heavy pages and you need a slider with, say, 10 slide images, you are in trouble. Let's do the math: Suppose each image is sized 100KB, then you need to put an extra weight of 1MB to your homepage! Traditionally, image sliders load all images from the html code and as soon as the page loads, a javascript comes in to make the magic happen. This means that a user must wait a long time before the webpage loads. Moreover, it is always better to display content on demand rather than pre-load it. It saves you from the extra bandwith and lets the web server breathe!

    Posted on January 10th, 2012 by Pantelis Petridis
  9. How to deploy a django application on a linux (Debian/Ubuntu) production server running ISPConfig 3

    Deploy a django application on a linux (Ubuntu/Debian) server running ISPConfig 3Figure 1. Deploy a django application on a linux (Ubuntu/Debian) server running ISPConfig 3

    Here's a quick tutorial to have your django application 'up and running' in a few minutes! This guide applies to Ubuntu/Debian servers running ISPConfig 3 (w. Apache 2) for domain management.

    Posted on December 20th, 2011 by Pantelis Petridis
  10. How to cache your website menu with django

    On large django projects it is more likely that to generate a single webpage multiple queries over large datasets and complex data processing must be involved. In such cases -were performance is an issue-, the use of caching techniques can really save the day. Django provides a solid framework for caching, allowing for the storage/retrieval of single values (e.g. the result of complex database queries), html code fragments (e.g. the 'footer' of your webpage) or even entire django views.

    In today's article we'll examine a way to cache our menu (consider a tree-menu application like the one described in this yawd blog article or the django-treemenus application) in order to reduce loading times and save db server load. Although this appears to be a fairly straight-forward task, a couple of decisions can be tricky.

    Posted on November 9th, 2011 by Pantelis Petridis
  11. How to keep your django project settings organized

    I like to keep my code organized. One of the issues I came across when exploring django coding is the 'settings mess'. Django settings are loaded on a project -and not application- basis. Having a single python module to define settings for a ton of applications is at least frustrating. When looking for a solution to this problem I found this blog post which cleared my head.

    Posted on October 9th, 2011 by Pantelis Petridis
  12. Embed the elRTE WYSIWYG editor in your django applications

    Screenshot of the yawd website admin panel - the elRTE django widgetScreenshot of the yawd website admin panel -the elRTE django widget

    Elrte is an open-source "What You See Is What You Get" editor written in jQuery. In my latest projects i tend to prefer this over other solutions (such as TinyMCE, (F)CKEditor etc) for its elegant UI, ease of use and mainly for its accompanying File manager (the elFinder). In this article we'll se how to integrate elRTE with django models, so that your text fields can take advantage of this editor.

    Posted on September 16th, 2011 by Pantelis Petridis
  13. Using class-based views to process a django form through ajax

    Field-specific errors with the JSONFormView class-based view Since Django 1.3 class-based views have been introduced to allow for code reusability. Class-based views have been criticized for their poor documentation (count me in) and their amazing ability to grow our code size instead of reducing it! The latter appears to be true only if we are not careful with sub-classing. On the other hand class-based views finally deliver django what has been missing: a consistent way of coding all your models, forms and views.
    Unfortunately, django's generic class-based views do not provide a mechanism for implementing JSON views. Ajax requests are the standard way of doing things these days and I feel that django needs some work towards this direction. However, the official documentation offers the implementation of a simple JSONResponseMixin that we will use as a base for our own view. What we try to achieve here is create a view that will process a form, return the errors when the form is not valid or save the form and return a success message otherwise. This is a fairly common scenario and extremely useful when a full page reload is not acceptable (e.g. a newsletter subscription form).
    Posted on August 30th, 2011 by Pantelis Petridis
  14. Allow for lazy dynamic choices in django's model fields

    Here's a quick how-to for those that need to dynamically generate model field choices with django. Normally we would define a CharField as follows, where choices should be a tuple containing static choices.

    Posted on August 16th, 2011 by Pantelis Petridis
  15. Migrate to Keystone 5

    If you want to upgrade your old Keystone TKL digital library and exploit the fast performance that Keystone 5 offers, here's what you most likely need to change. Please note that since PHP5 differs significantly over PHP4, you should also modify your custom PHP code, especially if it involves XML/DOM manipulation to work with PHP5.

    Posted on August 5th, 2011 by Pantelis Petridis
  16. Install Keystone 5 under Ubuntu/Debian

    In this article we'll see how to install Keystone 5 (ex. Keystone DLS (TKL)) under Ubuntu/Debian. I have tested the procedure using Ubuntu Natty (11.04) as well as Debian Lenny (5).

    Posted on July 21st, 2011 by Pantelis Petridis
  17. Use of classes and static variables with the Drupal 6 Batch API

    Drupal provides a nice API for anyone that needs to process a massive amount of data: the Batch API. This allows for running heavy scripts split into multiple operations while providing a progress bar to monitor the process' progress. However this API is not adequately documented and I had a hard time trying to resolve some issues I come across. I thought of sharing my findings in case someone else needs this.

    Posted on July 13th, 2011 by Pantelis Petridis
  18. How to add sitemap functionality in websites powered by django-articles

    Django-articles is an open-source blogging engine written in django. Unfortunately it does not offer a sitemap mechanism and since the yawd blog uses django-articles I had to implement it. If you have a django-articles powered website and want to add a sitemap here is how to do it:

    Download the sitemaps.py file attached to this article and place it under your project's main application. This module uses django's built-in sitemaps framework to define a...

    Posted on June 30th, 2011 by Pantelis Petridis
  19. How to automatically add taxonomy term relations when adding content in Drupal 7

    Let's suppose we want our Drupal article content type to have a parent category and a sub-category. We have defined a 'categories' vocabulary and we are also able to add new terms and set their parent elements. When using the administration UI to add a new article we can create a new category, set a new sub-category and both taxonomy terms will be saved along with the article. However, the sub-category won't be connected with its parent category automatically. We need to manually visit the taxonomy terms list and set the sub-category's parent category term.

    This is a problem I came across when working on a yawd project and to solve it I had to create a simple module that programmatically correlates the sub-category with its parent category field...

    Posted on June 29th, 2011 by Pantelis Petridis
  20. Keystone TKL framework for Digital Libraries now supports PHP5

    The past few years IndexData's Keystone Library framework has not been actively developed. When PHP5 was introduced back in 2004 it featured a completely redesigned Document Object Model (DOM) implementation that lacked backward-compatibility. At the same time, Keystone was heavily relying on XML manipulation, so it was not possible for these two to work together and Keystone users were forced to use PHP 4. IndexData at the time focused on other projects and officially stopped...
    Posted on June 24th, 2011 by Pantelis Petridis
  21. Scan additional PHP 5 .ini files in Eclipse PDT

    Although Windows systems seem to load all PHP 5 variables & extensions from a single php.ini file, there might be system configurations -especially Linux systems (Ubuntu in my case)- that use multiple .ini files. In such systems, PHP configuration is usually located inside the /etc/php5 directory: When running in cli mode, /etc/php5/cli/php.ini gets loaded along with all .ini files located in the /var/php5/cli/conf.d directory.. When using Apache, /etc/php5/apache2/php.ini and /etc/php5/apache2/conf.d/*.ini files are all loaded. The same is true for php-cgi. To load the additional .ini files, either a PHP_INI_SCAN_DIR environmental variable or the --with-config-file-path option can be used. So far so good.

    When it comes to Eclipse PDT, it seems that the additional .ini files are not loaded when PHP runs as script...

    Posted on June 16th, 2011 by Pantelis Petridis
  22. Using Aptana Studio 3 IDE for django applications - a "Hello world" tutorial

    Aptana Studio 3 is a development IDE targeting the most to web developers. Being an Eclipse-based platform, it runs as standalone application -it utilizes the Eclipse RCP framework-, as well as a plugin inside your existing Eclipse installation. I recently have decided to test Aptana for developing Django applications and this article covers Aptana's basic functionality.


    First of all we need to install Python. Python 3 was recently released, but version 3 is not supported by Django...

    Posted on May 31st, 2011 by Pantelis Petridis
  23. Admin widget for generic relations in django

    The contenttypes framework adds wonderful functionality for dynamic foreign keys in Django. However, it lacks of a widget to allow the user select the content object from the administrator website. This article explains how to implement such a widget and embed it to your django-powered project.

    Posted on May 26th, 2011 by Pantelis Petridis
  24. Using signals to generate a decoupled tree-menu application in django

    Although there exist several django menu applications -the excellent django-treemenus is one of them-, they all require that the user explicitly sets the menu structure. Consider the following scenario in a django CMS application: The user will probably be able to define a list of article categories -and sub-categories- and will also write a bunch of articles tied to each one of these categories. At the same time, this hypothetical user would also be able to use a blogging engine and publish his thoughts. Let's assume that the user wants to add an article category to the menu and use its sub-categories as sub-menuitems. He also wants to add a link to the blog main page and use the most popular tags as sub-menuitems. To accomplish this he must manually define a menuitem for each menu link and map it to the corresponding url, which is less than ideal. In this article, we will demonstrate a menu application that would enable the user to define a top-level item -e.g. an article category- and optionally have all children items automatically inherited from the corresponding parent element.

    Posted on May 20th, 2011 by Pantelis Petridis