Creating a Custom Manager for a MongoEngine Document in Django

posted by Herman on May 4, 2012, comments
This is just a quick how-to on creating a custom manager for a MongoEngine Model in Django, similar to how you would normally create a Manager for a Model in Django. Usually in Django with a PostgreSQL or MySQL database, one would do this: class PollManager(models.Manager):     def with_counts(self): ...... Read more
 

How to Choose the Best Startup Weekend Idea, and Get It Chosen

posted by Herman on March 28, 2012, comments
Startup Weekend - the global event that gives you one weekend to pitch, plan, validate and launch a brand new startup - is a great place to take your heap of startup ideas and get one of them validated (not to mention meet great people to build it with). But ...... Read more
 

Shorter Django Class-based Views Using Lambda Functions

posted by Herman on March 22, 2012, comments
A frequent pattern in Django Class-based Views, specifically when using it for forms, is the need to specify a success_url, like this: from django.views.generic.edit import FormView class MyView(FormView):     form_class = forms.MyForm     success_url = '/accounts/success/' However, you don't want to hardcode the URL like that, because that violates DRY ...... Read more
 

How to get Flash webcam to work on Ubuntu Linux

posted by Herman on Feb. 17, 2012, comments
If you're on Linux and trying to use a webcam Flash plugin, such as the one provided by Nimbb or red5-recorder, or many others to be found online, you might also run into this screen, as I did: Because of this, it took me about two hours of cursing to ...... Read more
 

Learning Django: Where to start and what to know

posted by Herman on Feb. 3, 2012, comments
A lot of people have recently been telling me that they want to start learning Django. That's great, and I'm happy to learn that the Django community is growing! To help all of you starting out with Django, here are some tips I'd like to share: Build Something The best ...... Read more
 

Setting the Instance on a Django Model Form Class Based View

posted by Herman on Jan. 9, 2012, comments
I've been converting some of my code to the new Django 1.3 class-based views recently, and I must say that overall, it's been quite a frustration. I see the merits of class based views. It has resulted in some shorter code in certain places, and helped avoid some duplication (that ...... Read more
 

How to Generate Pixel Perfect CSS Sprites in Inkscape

posted by Herman on Dec. 7, 2011, comments
Figuring out how to make pixel-perfect CSS sprites on Inkscape can be tricky if you're relatively new to it. Here's a quick how-to on how to make the sprite .png you see below, starting from just the separate icons for the first row. In it is contained some of the ...... Read more
 

Lessons Learnt from Startup Weekend, for Engineers

posted by Herman on Dec. 5, 2011, comments
This past weekend, I attended the Startup Weekend event in Hsinchu, Taiwan. It was a great event, well-organized and a lot of fun. The premise of Startup Weekend is simple: On the Friday night, anyone can pitch their idea in 60 seconds. The participants then vote on their favorite ideas, ...... Read more
 

How to create separate Name and Surname inputs as one widget in Django

posted by Herman on Dec. 1, 2011, comments
Today I'll show you a nice little trick that's useful if you want your new users to input their first name and last name separately, so that you know where the separation is. This allows you to say things like "Hello, Mr. Smith" or "Hello, Keanu" on your site, instead ...... Read more
 

November Startup Month... Go!

posted by Herman on Nov. 5, 2011, comments
Here at IronZebra, I've decided to partake in November Startup Month. It's simple, really: you have 30 days in which to conceptualize, design, build and launch an application to the world. Take one of those ideas you've had in the back of your head for a while, and do it. ...... Read more
 

How OpenID Global Authentication can be More Private, and Stop Spam

posted by Herman on Sept. 19, 2011, comments
I recently had an idea that any one-click authentication service would be able to implement rather easily, and (what I believe) to great effect. This is just a brain-dump of that idea, and I leave it here for anyone to steal and implement with my blessings (although a mention of ...... Read more
 

Do Certain Websites Need to be Ugly?

posted by Herman on Aug. 10, 2011, comments
I often hear web developers attribute the demise of MySpace to it's horrible design. At least, the horrible design it's users gave it by giving them too much freedom. I agree to some extent: technically-orientated people generally enjoy using the cutting edge, most beautifully designed sites, rather than the old ...... Read more
 

Element Inspector not Working in Chrome after Upgrade? Here's how to fix it

posted by Herman on June 4, 2011, comments
After upgrading Chromium on 64bit Ubuntu, I found that my element inspector suddenly started showing empty results. After some digging around, I figured out that the cause is that the chromium-browser-inspector package must also be upgraded, not just the Chromium package. To make sure it updates, I renamed /usr/lib/chromium-browser/resources/inspector, and upgraded the chromium-browser-inspector ...... Read more
 

Automatically sending your Django blog posts to Twitter and Facebook

posted by Herman on June 4, 2011, comments
Sending your Django website posts to Twitter, Facebook, LinkedIn and a whole array of other social networks is the easiest thing imaginable. Set up a Django Feed Start by setting up a RSS feed with the Django syndication feed framework. There are very detailed explanations and examples there, so I ...... Read more
 

Django: It's DRY, but you can sink your teeth into it

posted by Herman on June 1, 2011, comments
One of Django's core principles is the concept of DRY: Don't Repeat Yourself. Overall, the framework does a fantastic job at forcing you to follow that principle by default (and it's never a bad thing). Here and there, however, we need to add some initiative. I'd like to quickly share ...... Read more
 

Create random pronounceable passwords in Python/Django

posted by Herman on May 27, 2011, comments
An oft-cited problem with Django's built-in helper password generator make_random_password is that is that the passwords are very difficult to remember. Here's a short code snippet to generate passwords of the form 'snuskdrok33', 'swuspguf12', or anything with more syllables and more or less numerals.  # adaption of: # http://stackoverflow.com/questions/5501477/any-python-password-generators-that-are-readable-and-pronounceable # originally written ...... Read more
 

Google adds fade-effect on Google Maps

posted by Herman on May 17, 2011, comments
Somewhere in the last few days, Google rolled out a new feature on Google Maps that creates a graceful fade effect between zoom levels on Google Maps. The alteration, though small, creates a dramatic improvement in the usability of Google Maps. If you want to check it out, hop over ...... Read more
 

Call for Designers, Developers and Marketers to work on FlatSearch

posted by Herman on April 26, 2011, comments
If you're a web developer, designer or general web-enthusiast - we're looking for you. FlatSearch is expanding, and we're looking for brilliant web developers (who know at least JavaScript, CSS, and/or Django), web designers (with some previous web design experience) and driven marketers, who know how to convert an awesome ...... Read more
 

How to Make Zebra-Striped Tables with Django

posted by Herman on April 26, 2011, comments
In the spirit of IronZebra, I'll post a quick and easy tutorial on how to make a zebra-striped table, such as the one below, in Django. Method 1: The Cross-Browser CSS Way The easiest way to do this is to make use of the built-in Django {% cycle %} tag. ...... Read more
 

How to add full text search to your Django app with PostgreSQL and South Migrations

posted by Herman on April 19, 2011, comments
Note: In most situations, Django Haystack is the way to go for full text search in Django. But if Haystack is overkill and you only need simple full text search without installing extra packages and having to run scheduled tasks, read on to find out how to add full text ...... Read more
 

How to implement price changes on the web: a lesson from Coca-Cola

posted by Herman on April 12, 2011, comments
Running a web service is very similar to running a normal business. You have to deal with customers, pay salaries, obtain capital, expand to new demographics, and - very importantly - determine pricing. Pricing a web-service is sometimes a difficult thing to do. Since the marginal cost of the product ...... Read more
 

DraftEditor - Online Draft Editing Software

posted by Herman on April 12, 2011, comments
Sometimes one thinks about an idea for a website for a really long time. Especially when it's an idea that you could use yourself, but is just not quite important enough to do right now - there's something else that just be might be more productive. Well, DraftEditor was one ...... Read more
 

Converting Multi-dimensional Form Arrays in Django

posted by Herman on March 31, 2011, comments
When you're working with Django and jQuery, you'll find that Django lacks some support for handling multi-dimensional form arrays. Let's say that you have a form where you don't know how many entries is to be expected, and you would like the user to add new fields as necessary. Here's ...... Read more
 

The difference between jQuery bind() and live(), and where to use which

posted by Herman on March 28, 2011, comments
One of the things that makes jQuery so nice is its bind() function. This function is the primary method to attach events to your document. Any event (such as click, mouseover, mouseout, resize, or even your own custom events), can be bound to any HTML elements using this method. Then, ...... Read more
 

Web development in Taiwan

posted by Herman on March 25, 2011, comments
This post has been removed, sorry! If you want web development done or your website translated for the Chinese or Taiwanese market, don't hesitate to contact us.... Read more
 

Cricket World Cup 2011 on SABC

posted by Herman on March 24, 2011, comments
For those of you who have been wondering, like me, why the first quarter-final match between Pakistan and West India was not broadcast on SABC, it is because the SABC only obtained rights to broadcast 2 out of the 4 quarter-final matches, 1 out of the 2 semi-finals, and the ...... Read more
 

APE vs Orbited - The Comet wars

posted by Herman on March 23, 2011, comments
I've spent some time the last couple of days getting to grips with APE - the Ajax Push Engine, an open-source library for Comet. My goal is to have a Django application that is augmented with Comet push capabilities. APE After about a day of setup, I got a basic ...... Read more
 

Using server-side javascript with APE (Ajax Push Engine)

posted by Herman on March 22, 2011, comments
One of my main complaints with APE is that the documentation is scarce and badly written. It took quite a while to figure out how to add my own serverside javascript files in APE. Note that I'm running Ubuntu 10.10, and I installed Ape through the debian package. The path ...... Read more
 

How to design a good to perfect 404 page or error page

posted by Herman on March 19, 2011, comments
In the ever-changing world of the Internet, it is inevitable that at some point in time someone will click on a link, or mistype an address that leads to a page that does not exist, or causes some sort of internal error. Even if you take the greatest of care ...... Read more
 

Protecting your site's cookies from Cross Site Forgery (XSS) in Django

posted by Herman on Feb. 18, 2011, comments
There's an excellent post by Jeff Atwood about protecting your site's cookies from being used in one of the most common forms of XSS attacks. What it boils down to, is to set the HttpOnly attribute on the cookies you use in your site, especially those that are used for ...... Read more
 

Rapid HTML development in Kate, using Zen Coding and the Insane HTML plugin

posted by Herman on Feb. 18, 2011, comments
There's a little-know feature in the latest versions of Kate (the open source text-editor) that allows developers to generate html markup in a flash.  It happens using a plugin called Insane HTML, which is based on the Zen-coding project. This allows us to type CSS selectors, such as the following: ...... Read more
 

Debugging IE in Ubuntu

posted by Herman on Feb. 17, 2011, comments
Debugging websites in Internet Explorer on Linux systems can be a pain, especially if you specially first have to install a virtual Windows envrionment, then get all the versions of IE, etc etc. But luckily there's an easier way to run IE in Ubuntu. Ubuntu has a package called PlayOnLinux. ...... Read more
 

FlatSearch South African Apartment Search Alpha Version Launched

posted by Herman on Feb. 11, 2011, comments
Woohoo! The first, early alpha version, of FlatSearch is now online. Go check it out at FlatSearch.co.za - Find Apartments. Only apartments in Stellenbosch are kept up to date during the Alpha phase. As exciting as this preliminary launch is, we're still a long way from where we want to ...... Read more
 

FlatSearch nearing Alpha phase

posted by Herman on Feb. 4, 2011, comments
There hasn't been news from our side in quite a while. This is because the IronZebra incubator has been in a whirlwind of caffeine-fueled activity the last few weeks. We're readying ourselves for the public alpha-launch of FlatSearch, the best apartment search South Africa has ever seen. What does it ...... Read more
 

Installing Celery for Django

posted by Herman on Jan. 23, 2011, comments
Here's a quick and rough guide on how to install Celery for Django on Ubuntu, aimed at refreshing the memory of those who've done it before.  Install rabbitMQ (instructions here) Install Celery (detailed instructions here) easy_install django-celery On the console, type the following (change the infomation where needed, 123 is ...... Read more
 

Django: Showing the help_text of a model field as a title attribute in the form

posted by Herman on Jan. 22, 2011, comments
Maybe it's just me, but I find the standard way Django outputs the help_text on form elements quite annoying. If you use form.as_ul, it looks something like this: <li><label>Label text:</label><input type="text">This is the helptext.</li> Which is great, except it's really difficult to make it look nice. What I would rather ...... Read more
 

List of Django Model _meta fields options and methods

posted by Herman on Jan. 22, 2011, comments
I've found out that it's almost impossible to find a list of all available _meta options for models in Django. Well, here is one, for both my own and your reference. Be warned, however, that these are internal options to the Django system, and can change at any time. But ...... Read more
 

How to get comments for a certain object in Django

posted by Herman on Jan. 21, 2011, comments
The Django documentation gives very detailed explanations of how to show comments for objects in templates, but makes no reference to how to actually get the comment objects associated to a certain object when your still in the view. Well, there's a handy little function for that, called for_model, which is used ...... Read more
 

How to smoothly zoom in on an object in Google Maps V3

posted by Herman on Jan. 20, 2011, comments
When wanting to zoom in on a specific object in Google Maps (e.g. on double-click), the API provides no good functionality to zoom in onto the object smoothly. Here is a short snippet on how I achieved the effect. As always, any comments, suggestions and alterations are welcome! // example ...... Read more
 

How to test whether a javascript variable exists

posted by Herman on Jan. 19, 2011, comments
Now and again, especially when working with different files and dependencies in Javascript, it's useful to be able to check whether a variable is defined without risk of getting a 'x is not defined' error. There is a neat trick to do it, which makes use of the javascript window ...... Read more
 

Trudging through the Turing Tarpit

posted by Herman on Jan. 19, 2011, comments
Turing tarpit is a general term for a programming language or computer interface which allows for a great deal of flexibility in function but is difficult to learn and use because it offers little or no support for common tasks. The best wording for it I've heard is this: It’s the place ...... Read more
 

Sending the url of a thumbnail from Django with sorl.thumbnail

posted by Herman on Jan. 16, 2011, comments
Sorl.thumbnail is a fantastic (in my opinion the best) thumbnailing library for Django. The documentation isn't all that great though, and it takes some figuring out how to actually send just an URL string from Django to the template, instead of using the template tag (which is normally very useful). "Why ...... Read more
 

How to quickly create a Django edit form from object instance

posted by Herman on Jan. 11, 2011, comments
One of the great things about Django is that it makes creating forms painless and easy. However, it's not always obvious how to do certain things if you don't already know the functions. Creating an "edit form" from an existing Model object instance is one of those cases. For this ...... Read more
 

How to display a custom error page for HTTP status 405 (method not allowed) in Django

posted by Herman on Jan. 10, 2011, comments
I recently realized that, despite Django having the built-in (and very useful) @require_POST decorator, there is actually no easy way to display a nice error page if the user accidentally stumbles onto a page using a GET request (or vice-versa for the @require_GET decorator). In fact, Django doesn't even show the usual ...... Read more
 

Website online

posted by Herman on Jan. 9, 2011, comments
Hooray! Just in time for the new year, the IronZebra website is launched. We hope to soon have the site buzzing with information about web development, Django, the projects we are busy with and all things interesting.  We will take the South African web world by storm, and we're not ...... Read more