Hello, reader!

My name is Eugene Lazutkin.

I'm a software developer based in the Dallas-Fort Worth metroplex. Lazutkin.com is my professional blog, which contains short writeups and presentations regarding modern web applications. All articles here are written by myself, unless stated otherwise.

tag: Django

Using Dojo Rich Editor with Django's Admin

Many years ago I decided to replace plain text areas in Django’s Admin with rich text editor, so I can edit HTML on my blog using WYSIWYG. Six (yes, 6) years ago I looked around and selected TinyMCE. Over time it turned out that I was forced to upgrade TinyMCE and the link script I had because new browsers continue breaking my rich editor editing. Finally it stopped working again in all modern browsers, and I decided that enough is enough.

Adding django-shorturls

6 Aug, 2009 - 5 minutes
Time to time I sync my blog software to the Django trunk and introduce small enhancements. Some of them visible to my readers, some of them are just for me. This time after reading Simon Willison’s post on rev=canonical I decided to add short URLs to my blog as well. This is a convention to provide custom short URLs managing the mapping on your own web site. In my opinion the idea is very cool.

Google App Engine: the first look

8 Apr, 2008 - 5 minutes
Yesterday Google announced its new offering: Google App Engine. These are my random notes I did yesterday when I studied the new service. Google didn’t go the same way as Amazon with its AWS. The former offers a form of shared hosting (think “distributed WebFaction"), while the latter offers a virtualized environment (think “distributed SliceHost"). So basically we are talking about more high-level approach to web applications, which is easy even for novices.

PyCon 2007 pictures

24 Feb, 2007 - 1 minutes
I published first day pictures from PyCon 2007. They are raw, unedited, I didn’t put descriptions yet. You can recognize Django guys, people from multiple Python web frameworks, and, of course, the BDFL with OLPC. But why wait for pictures to be prepped? Dig in while they are raw and fresh: Yes, this is Steve Holden sporting a Django t-shirt. Update: I added pictures from the 2nd day. Update #2: I added pictures from the 3rd day.

Improving performance of Dojo-based web applications

Introduction Web 2.0 brought on us an onslaught of new server-side web frameworks, and made it OK to put some code on the client side as well. Yes, I am talking about Ajax. While elements of Ajax were available (and used) for a long time now, 2005 was the crucial year for this relatively old technology fueled by proliferation of modern browsers with proper support of JavaScript and HTML DOM, which, in turn, gave a rise to numerous Ajax toolkits.

Setting up tools 2

This is the 2nd part of Setting up tools on Windows — notes mostly for myself. (No, I don’t run Django with MSSQL under IronPython. Yet.) In this installment I add more stuff to Eclipse, and set up my apps under FastCGI on Linux-based shared host (I use DreamHost). Eclipse This section was updated on 9/30/2006. I already set it up with PyDev and Subclipse. Now I want to add HTML/CSS editing.

Migration to magic-removal

6 May, 2006 - 2 minutes
Today I converted three web sites to the latest Django’s trunk formerly known as the magic-removal branch. It was a very positive experience in general. New Database API with lazy database queries (courtesy of QuerySet) rocks! Direct interaction with model classes allows doing a lot of things much simpler than it was before. A lot of small improvements, which makes a big difference like explicit template extensions (use whatever is appropriate for your content), more transparent new Admin inner class, natural overriding of model methods (no more _pre_save() and _post_save() hooks!

Google Summer of Code 2006

2 May, 2006 - 2 minutes
Yes, another Google SoC is upon us. I signed up as a mentor with Dojo and Django. Both projects are on the leading edge of new wave of web-based applications doing extremely cool stuff. I anticipate that some smart students will bridge both projects, but individual projects are fine too. What is Google SoC? Read the FAQ. Who can apply? Any student anywhere in the world can apply. You don’t have to be Comp.

Finalizing PyCon 2006 pictures

4 Mar, 2006 - 1 minutes
I found some time to finalize my pictures and notes on PyCon 2006. I tried my best to identify people in my pictures. Now you can see their names and links to their blogs. I added links to official descriptions of their talks, as well as to excellent detailed notes of some talks by Steve Holden. I advise to visit his blog, because he has notes on some talks I didn’t attend.

PyCon 2006 pictures

26 Feb, 2006 - 1 minutes
Here in Dallas PyCon 2006 gave us an opportunity to meet many "virtual" people from Python community, and put faces to names. For those who couldn’t attend I am publishing pictures and small notes on Flickr. I will add more pictures tomorrow. If anybody’s name is misspelled, or missing (I didn’t catch all names), or you want me to remove your name or picture, please contact me and I will change notes.

Setting up tools on Windows

Update 9/30/2006: when you finish this article don’t forget to read more about setting up tools in the second part: Setting up tools 2. My goal is to set up working environment for Django development on Windows box. You can find a lot of information on setting up open-source development tools on Linux. Somehow it is assumed that your project should target LAMP (Linux, Apache, MySQL, Python). Windows-bound guys are advised to decorate their platform as ersatz Linux: install Apache, install MySQL, and you have WAMP (Windows, Apache, MySQL, Python).

Looking at stats: Google Video

2 Feb, 2006 - 2 minutes
Let’s take a look at Snakes & Rubies stats published on Google Video. But before that take a look at previous stats published on 1/27/2006. New stats include 5 more days covering 18 days of January 2006. Lessons: More people read Django Community RSS feed than the news group, which was used for previous announcement. Duh. People followed my advice and went to watch Q&A Session. Very good! I know you were not disappointed.

Python web frameworks

31 Jan, 2006 - 1 minutes
Now after two posts about Guido’s quest for the Right Web Framework (1st, 2nd) I am starting to feel like his relay station. But I want to share his comment made in Matt’s blog post on Python web framework shootout: Why criticize Django for claiming to be the best? Nobody has denied it, and yet it’s criticized as if it were somehow unethical. Frankly, the problem is that there are too many Python web frameworks and wannabees, and if we don’t start some kind of shootout, however subjective, we’ll never get to market dominance of a few good ones.

Django Dojo

28 Jan, 2006 - 2 minutes
Django-Dojo alliance was finally announced to the world by our very own Jacob Kaplan-Moss: Starting with version 0.92 (which should be out in a few weeks, Murphy willing), Django is going to bundle Dojo with the toolkit. Specifically as part of Django’s admin interface (but available to user apps as well). Read all about it in Jacob’s post. I am overjoyed to see such cool high quality open source projects are working together.

Full Snakes & Rubies video is live

27 Jan, 2006 - 2 minutes
Finally full Snakes & Rubies video went live on Google Video! And it took only 18 days to verify it (19 days, if you count when I started to upload it). Apparently the whole process of verification depends on file size nonlinearly. It cannot depend on content because it is a combination of smaller files: Adrian’s Django presentation, David’s Rails presentation, and Q&A session. Oh, well. And now is time for some stats (1/9/2006–1/27/2006):

Live Filtering

Update on 11/25/2007: today this article presents mostly historical interest. Since Dojo 0.2 a lot of versions were published and many things were changed. At the time of this writing Dojo is at ripe 1.0. I had to disable all Ajax action in examples because I don’t use Dojo 0.2 anymore. What is Filtering? It is a selection of items using some criteria (filter). In this tutorial I am going to filter documents of my blog (made with Django, of course) matching titles against user-specified substring.

Snakes, rubies, and some comments

12 Dec, 2005 - 2 minutes
A week ago I posted a link to David’s take on "Snakes and Rubies" event. Of course I am talking about article written by RoR’s creator. It is a great read, but this time I’ve read reader’s comments (or "challenges to the Loud Thinking"). Oh, boy! It gives you insight into Rails, Django, and their perception by developers and users. For example, I am not very familiar with i18n problem, but it looks like a lot of people were quite passionate about it.

Django Ajax Redux

10 Dec, 2005 - 9 minutes
Three weeks ago we had a discussion about Ajax support in Django, which resulted in "Ajax and Django" wiki page. A short recap: it lists a vague goal, some general considerations, and possible strategies; it scratches the surface of existing implementations (mostly RoR), existing third-party toolkits (Mochikit/Dojo), and related RPC-style and REST-style services. No code was produced, no consensus was reached, but now it is a part of Django’s Version One roadmap.

1st news on Django/Rails bash

3 Dec, 2005 - 1 minutes
Rob Lambert just posted his thoughts on Snakes and Rubies event in Chicago today. I am sure we will have more info later (including promised video) but it is an interesting read anyway. And it is available now. Update: Eric Sinclair posted his notes on the event.

Different people, different opinions

30 Nov, 2005 - 2 minutes
It is practically impossible to travel to Muslim countries without hearing some anecdotes about Nasreddin Hodja. Here is one (the source): Hodja was once a judge. One day a man came to his house to complain about his neighbor. Hodja listened carefully and then said to him, — My good man, you are right. The man went away happily. In a little while the first man’s neighbor came to see Hodja.

London presentation

20 Nov, 2005 - 1 minutes
I found a blog post describing London Web Frameworks Night, which took place on 11/17/2005 at the University of Westminster. Jabbering Giraffe reports on presentation of three web frameworks: Catalyst, Django, And Ruby on Rails. It is an interesting read. Author remarks that Django’s Admin ("with lots of Ajax and JavaScript goodness") was the main object of envy of other frameworks. Another interesting remark was how good Rails people are at marketing.

New RSS framework

12 Nov, 2005 - 1 minutes
As you all know Django has new shiny RSS framework. This change breaks my simple RSS tutorial and I am glad that it happened! To tell you the whole truth, it breaks only "The Simple Way" to do RSS in Django replacing it with even simpler one. "The Smart Way" RSS still works as you can see on my web site. Like I predicted the feedgenerator is still around and it learned some new tricks: it can produce Atom feed now!

Looking at stats

10 Nov, 2005 - 3 minutes
Recently I looked at the stats of my web site. DreamHost provides Analog 6.0. I supplemented it with awstats. Plus there are some other means to analyze the traffic. Let’s put it this way: I know my average reader. I thought I did. Anyway I found a few surprises. The country list includes 77 countries. Out of 193. Not bad for a personal blog. Practically all Eurasian countries, and countries of both Americas are in the list.

Django goes international

4 Nov, 2005 - 2 minutes
As of today i18n branch of Django is merged back to trunk. What is i18n? It is an abbreviation of the big word "internationalization". l10n ("localization") is a sibling of i18n. In practice it means that now you and I can do truly international multi-language web sites without much hassle. While this is more important for big corporations and international organizations, it is a big step for Django’s truly international community.

Migration to new Django admin

19 Oct, 2005 - 1 minutes
I’ve migrated my sites to new Django admin. It is easy to do but make sure that you followed instructions closely. Small mistakes can cost you a lot of head-scratching time. You can find the instructions at the bottom of Backwards-incompatible changes. New refactoring has totally made sense. Meanwhile Robert Wittams & Co is working on new-admin (note the hyphen). Django’s admin is a very nice app (now it is an app!

New TinyMCE config for Django

25 Sep, 2005 - 1 minutes
For a long time I wanted to have two TinyMCE toolbars for Django Admin: One-line toolbar with the most essential tools, which gives a lot of space for inline editing of text. Full-featured toolbar with all tools for full-screen mode. It finally happened. Spocke (the main developer of TinyMCE) helped me to figure out how to do it. I updated my article in Django Wiki with new config file, and removed my notes about space problem (new config file solves it) and flickering (new TinyMCE 2.

Code: RSS in Django

23 Sep, 2005 - 9 minutes
Update: "The Simple Way" part of this tutorial is obsolete now. I am going to recreate examples using new improved RSS framework. Stay tuned! I was asked several times to explain how I did RSS for my site. Django has RSS framework, which is not documented. Most probably I am not the right guy to explain it but I’ll try. There are three ways to implement RSS with Django: The Simple: using Django’s RSS framework.

Code: my categories

After some requests I decided to publish my code for categories. It’s very simple. It was inspired by following articles: A "category" Data Model (note: this article uses old-style model format, it doesn’t work anymore) and Relating an object to itself, many-to-one. from django.core import meta class Category(meta.Model): """ Category defines following fields: name - simple name of category, e.g., 'C++' full_name - full name of category, which includes names of all parents, e.

Django badges!

16 Sep, 2005 - 1 minutes
Finally we have official Django badges. Wilson Miner did a great job putting them together. I decided to use this one: How do you like it? If you are a fan of 80 by 15 pixels badges, don’t fret — Dave Hodder has you covered with his rendition of "Made with Django" theme. Collection of his small badges are attached to ticket #509. Check it out too.

Added RSS

Finally I added RSS 2.0 using Django’s facilities. Default RSS feed is for my blog. Categories have two versions of RSS feed: exclusively for documents of the category, and documents for the category and its children. (I hope it is not news anymore: I have hierarchical categories.)

Running on 'sql:' cache now

Now this blog runs on sql:. I use MySQL as my backend. Before that I tested it locally with SQLite (so easy to install!) and MySQL. I learned today that MySQL, which is provided by my host (DreamHost), uses MyISAM for all tables. MyISAM doesn’t support transactions. AT home I use InnoDB, which supports transactions. However the hope is not lost — DreamHost mulls over InnoDB support. But as far as I know, they don’t have an implementation schedule yet.

Something wrong with simple cache

9 Sep, 2005 - 1 minutes
I am not talking about multithreading problems. locmem: doesn’t have them. But it does have problems with gzip. Sometimes I see binary stuff on my screen. It looks like a gzipped web page without proper gzip encoding flag. I don’t do anything related to compression in my cache. Is it a bug in Django’s caching? Hmm… Apparently it works properly with memcache. Can it be some bug in simple: implementation, which was a base for locmem:?

Say no more! Say no more!

8 Sep, 2005 - 1 minutes
Being a little bit frustrated by the lack of caching options for my web site I’ve added locmem: cache to Django. It is fully multithreaded local memory-based cache, which uses reader-writer lock to do its magic. It seems to work well but I need some time to test it more. I think file: is going to be next.

Django on Dreamhost: happy end

7 Sep, 2005 - 1 minutes
It looks like all kinks with Django on Dreamhost were worked out. Of course, I am referring to MySQL problem (see my previous post) and strange stalling of long pages, which I reported to Django’s mailing list. It turned out that other people had these problem too. Jason McBrayer shared his experience. He pointed out to possible flup/fcgi.py problem. I contacted Allan Saddi — the author of flup and other Python libraries and utilities.

Django with MySQL: problem solved?

5 Sep, 2005 - 1 minutes
It looks like the problem is solved. Django creates one (1) connection to database and reuses it to handle requests. Multithreaded FastCGI creates threads to handle requests. These threads make requests to MySQL, which gets confused and loses its cool^H^Honnection. This process is random and compounded with multiple web requests at the same time. For example, if Google Web Accelerator decided to prefetch some pages, your web site would be hosed.

More on MySQL and Django problems

5 Sep, 2005 - 1 minutes
I complained about instability of this site in my previous post. Now, after intensive googling, it looks like it may be related to multiple threads or forked processes using the same connection to MySQL. Apparently it can confuse MySQL. Children should create their own connections after spawning. If Django does reuse connections, it may be possible to fix it. Otherwise, CGI is the way to go. The latter solution would be slow.

Django and MySQLdb worries

4 Sep, 2005 - 2 minutes
I am totally at loss. I am getting weird errors like this: OperationalError: (2013, 'Lost connection to MySQL server during query') They are pretty much random but fairly frequent. Apparently it may be caused by different MySQL timeouts, which I cannot control. It seems that in order to combat those you have to call connection.ping() periodically to reconnect. I added them to Django’s MySQL handler and … now I am getting these errors during execution of connection.

New Design 0.1 is here!

New design is here. Well, some elements of it. I had bigger ideas, but CSS didn’t work reliably, and JavaScript option was in debugging mode. So I decided to update this site now and add other planned stuff later. One reason I postponed JavaScript thingy is I want to try Dojo. It looks like a good foundation for widgets. I am going to create a couple of them at least. If it works okay, I’ll be using it in other projects as well.

New Design 0.1

29 Aug, 2005 - 1 minutes
New design is coming along nicely. Thank heaven for Photoshop, POV-Ray, and digital cameras! I need to work out a few quirks and I’ll be ready to create Django templates. Additionally I’ll create some custom tags to handle non-traditional formats.

Using TinyMCE with Django's Admin

26 Aug, 2005 - 2 minutes
Update (3/13/2011): this article is obsolete now and preserved here mostly for its historic value. Nowadays I use Dojo’s dijit.Editor as a WYSIWYG HTML editor — it is more functional and much simpler to setup and extend. Read all gory details in Using Dojo Rich Editor with Django’s Admin. I decided to add a WYSIWYG editor to my admin portion of the site. Apparently you can find some nice open source WYSIWYG editors nowadays.