Showing posts from July, 2011

Django: Beautiful multiple files Upload Plugin using jQuery UI.

After successful developing python back-end for Sebastian Tschan jQuey Plugin  I've decided to make a reusable app for that purpose. So:

This is a plugin, made using multiupload form from Sebastian Tschan.
It uses jQuey UI and jQuery instead of Flash uploader.
On Django side it uses sorl-thumbnails and PIL.
You can use it in your applications with simple inclusion tag

jQuery Features it has:
Multiple file upload:
Allows to select multiple files at once and upload them simultaneously.Drag & Drop support:
Allows to upload files by dragging them from your desktop or filemanager and dropping them on your browser window.Upload progress bar:
Shows a progress bar indicating the upload progress for individual files and for all uploads combined.Cancelable uploads:
Individual file uploads can be canceled to stop the upload progress.Resumable uploads:
Aborted uploads can be resumed with browsers supporting the Blob API.Chunked uploads:
Large files can be uploaded in smaller chunks with br…

Django: Creating multi upload form without using Flash

Hi there! Today I want to tell you about my experience of adding Multiple files upload form to my Django project Photoblog. I searched google for lots of plugins, but found only Flash usage examples. I dislike Flash technology, as for my personal usage, and want to build some more quickly working UI. Personally I have flash blocker installed on my browser. So that's main ideas pf my jQuery plugin selection. I found IMHO the best for my case plugin by Sebastian Tschan. It had only one problem - No available Django examples. Let's try to fill the gap here... So my experience on befriending Sebastian Tschan's jQuery File Upload Plugin with Django is the topic of this article. Let's finally get started. :)

Sebastian has built an important plugin IMHO. I want to thank him for his noble work of helping people with their tasks. It uses only jQuery UI and no flash, making it work more programmers way... So enough with the lyrics.

Let's try to adapt his example to a django …

Django: How to add Google +1 button to your website.

What is Google +1 button?It's new Google social button. It's much similar to Facebook "Like" button. While available during one month it earned popularity that could compete with Facebook's social button. Corporation of Good knows what to do, so you probably want to have one on your website inline with Facebook's Like...
Add Google +1 button to your site:- Open and generate own button for your website.Google proposes HTML code like this:
<html><head><title>+1 demo: Basic page</title><linkrel="canonical"href=""/><scripttype="text/javascript"src=""></script></head><body><g:plusone></g:plusone></body></html>
It's quite simple, as you can see. And that's much pretty it. Oh no wait...
- Add some variable to your template like "g…

Django: Setting up Django virtual environment via python Virtualenv with Eclipse. Quick guide.

Hi! Let's talk about Django ways to code. First you have to have environment installed for work with Django. Today I'll try to show you my way of using virtual environment (python virtualenv).
It's ok to handle package dependencies in Django apps by simply manually putting libraries, are in need for your project, into project PYTHONPATH. It's an easy way to do it. BUT what if you would like to make another project with this environment (e.g. the same modules, plugins or app's set)... You will have to add all those modules to your new project. Another issue that if would like to code for existing project, like for e.g. open someone's work and add some modules to it. Virtualenv is a newly fashioned package which aims to combine the best features of a workingenv with a virtual Python install. Also you can say that it is a tool to create isolated in a sandbox Python environments. So... This article is about how to set up, run and connect to Eclipse new dja…

How to disable/enable an element with jQuery or Javascript


Sometimes you need to disable/enable the form element like input or textarea. Jquery helps you to easily make this with setting disabled attribute to "disabled".
For e.g.:
//To disable  $('.someElement').attr('disabled', 'disabled');

To enable disabled element you need to remove "disabled" attribute from this element or empty it's string. For e.g:
//To enable  $('.someElement').removeAttr('disabled'); // OR you can set attr to ""  $('.someElement').attr('disabled', '');


My case was a bit different. I had to disable simple control element used without a form. <aclass="rotator"href=""onclick="return rotate(this, parameter, url)">
I made a javascript like this:
/** script */ var disabled = false; function rotate(button, parameter, url) { if (disabled) returnfalse;     disabled = true; /** some before post operations like making element visually          dis…

Django: upgrading django from 1.1 to 1.2.5 and CSRF protection modifications

Yesterday I completed a quick upgrade from django version 1.1 to oldest supported 1.2.5. I had a lot of background for doing so:
- Fist my hosting has django 1.2.5 already installed.
- Second I had some thoughts on using old stuff. It's better to evolve in Djngo version too :)
- Third and the main: Newly found on Google social authentication plugin was the final dot in my decision...

So I'll try to provide My experiences on migrating (updating) my project's Django from version 1.1 (developed on it) to oldest now supported 1.2.5.

Let's get started.

1. Read the release 1.2 docs. 
I needed a quick solution. In general I had some issues with site giving me errors with {csrf_token} not present in a form's POST request.

To handle this and IMHO main issue upon upgrading you have to handle Cross Site Request Forgery protection backwards incompatible upgrade.  You can read official django docs about new CSRF protection and/or use this quick manual.

2. Add CSRF Mid…

Briss Trims PDFs so They Fit Better, Are Easier to Read on Your Kindle

Windows/Mac/Linux: Virtually every current ereader offers native support for the PDF format, but no PDF was designed for your ereader's 5-7" screen. Briss, a cross-platform open-source tool, gives you several ways to trim PDFs to look better on your ereader.

Briss's user-interface is spare but simple. After loading a PDF file, Briss scans the document to identify and group pages with the same approximate structure into different batches. With books, it's usually even- and odd-numbered pages, because of the way the margins line up. The genius part is that you can trim every page in a batch to exactly the same size and shape, all at once. Start at a corner and drag a blue rectangle over the area you want to keep, then repeat for each batch (see the screenshots above and below).

Briss is particularly good for three things: trimming enough negative space around the text to make the document readable on a small screen, converting two-page "spread" landscape docu…