Archive for the “Web Development” Category

Integrating Uploadify with Django

29-07-2011 Alec Hussey 5 Comments

As multimedia becomes more and more prevalent these days, an interactive file uploader becomes extraordinarily useful. I ran into such a situation recently when developing a Django web application of my own. In this case I chose to use Uploadify because I’ve used it in the past, it integrates well with jQuery, and in my experience has been not only the easiest to work with but the least problematic.

Working with flash-based file upload systems is relatively easy with Django assuming that they send a standard POST request to the server and you understand the way Django chooses to handle file uploads. Django provides file upload handlers which may be modified to perform more sophisticated tasks during file uploads if you wish, but in this case we will stick with the built in upload handlers. When you upload a file to a Django view it takes the name of the upload field in your template and puts that name into the request.FILES dictionary where the value of that entry is an UploadedFile object or a subclass thereof. This UploadedFile object contains basic information about the file being uploaded including its file name as it was uploaded and its complete size. In addition, it gives you file-like access methods to the uploaded data which allow you, the programmer, to decide how the data gets stored.

(more…)

Filed under:
Tags: , , , , , ,

Integrating TinyMCE with Django

09-12-2009 Alec Hussey 9 Comments

Many people often want What You See Is What You Get (WYSIWYG) editors when creating content from within their web applications. This can be either in the Django admin control panel or for the end user. One of the most flexible and useful of the WYSIWYG editors currently available is TinyMCE due to its extensive plugin library and robust feature set. Integration with Django is relatively simple given that you extend the functionality of built in classes.

The first thing we will need to do is create a custom widget from forms.Textarea found in the django.forms module. We accomplish this by inheriting the Textarea class and overriding the constructor and render methods. Defining the relative path (on your web server) to the TInyMCE javascript source is also required here. So be aware that you will need to change that path to suite your environment. You may also want to change the content_css variable to include your sites’ main CSS file. The following is the source code for widgets.py which should be place in your projects root directory.

(more…)

Filed under:
Tags: , , , ,

Reusing 3rd Party Libraries in Web Development

Ever since I have been getting back into the swing of Web Development, working on one of my projects, I really took notice to something. Whenever you see a PHP application out there that is free to download and you start looking through how they did things. You start to see that generally many web application developers (particularly PHP developers) will tend to rewrite many back end libraries for things such as the templating engine or database abstraction layer (DBAL) when there are so many libraries which do exactly the same thing and in many cases, much more. So my question is, why are we as developers wasting so much of our time rewriting things which are already there for us instead of using them to reach our intended goal? I recently asked myself this question while working on one of my projects.

I realized that I had wasted several months of my time developing what I called a “framework” for PHP when it was really not very full featured and actually made things extremely hard for myself in the large scheme of things. After doing some homework, I had found really rich libraries that allowed me to do things beyond my wildest dreams before. Projects such as Smarty, jQuery, and TinyMCE just to name a few. What really gets me though is that many free (as in beer or potentially as in free speech) projects constantly fall behind because they take  forever to their own things such as rich text editors and ajax frameworks while their users are wondering why they don’t have the features they are looking for.

So  this is a call to all web developers out there. You really need to start reassessing  the libraries you write and think of how you could possibly use others’ great Open Source projects to assist you in the development of your application. Stop reinventing the wheel and start innovating, that’s what we are all about, right?

Filed under:
Tags: , , ,