Yawd website

Articles Tagged django

  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. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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