Change a django password manually

Posted by in Software

The other day I’ve been confronted with a strange situation: I forgot the admin password for a django application. I was playing with installing my own pypi repository, I’ve configured and deployed a test application and, after a couple of weeks, I forgot the password. I tried several times bu I knew that I used something silly and… unfortunate. Even worse, the user name I thought I used was not the one I had set up for the test. Oops :) After looking online for options I’ve found the following:…read more

Python classes to generate CSS

Posted by in Idea, Software

A while ago I got fed up with CSS and its cumbersomeness. As my poison of choice is python, I was thinking it would be quite useful to have a bunch of classes capable of generating CSS automatically in python. One could have a base class, a set of properties, a name-value dictionary and a way to nest them nicely so we could emulate LESS/SCSS. The idea is to use the power of python (or whatever language you’d want), with nesting etc. so we allow non-web designers mess around with…read more

Formless Step in FormWizard

Posted by in Software

Sometimes you’d need to show a purely informational page as part of a FormWizard. As far as I could see, there are two solutions to the problem: If the info is something like a summary, you have it available in the “success” page (the one after the wizard is finished) Alternatively, you can make it a page in the wizard. The more challenging and versatile variant is the second one (versatile because it gives you the possibility to go back to a previous step to correct stuff). My Solution My…read more

Create Data Once in a FormWizard

Posted by in Software

At one of the sites I’m building I need to walk users through a registration process: Select a supported tool Generate an ID Create a configuration based on the previous two steps To do this, I chose to use a FormWizard with three steps, one for each of the above. The problem then becomes to generate the ID once per wizard iteration. Initial Approach(es) Various online solutions (and even in the FormWizard documentation) suggest using get_form_kwargs() or get_form_initial() to build step-relevant data coupled with the get_cleaned_data_from_step(). The get_form_initial() method is…read more

Easy django applications with cookiecutter

Posted by in Software

Now I’m trying to create a bunch of django applications and I’ve got tired of creating everything from scratch. So, here are the steps I’m using to easy create a new django app: Create a new virtual environment. This is vital. It allows you to set up your own versions, not pollute the default installation (removing packages is tricky IMO). If you don’t know what I’m talking about, spend a few minutes to find out. Install cookiecutter (pip install cookiecutter). This is according to some the best thing that happened…read more

Make pyflakes/pylint ignore unused imports

Posted by in Software

Sometimes, you need to add an import without explicitly using it, just to have stuff defined. In such cases, both pyflakes and pylint generate messages, which can be annoying. For example django-appconf has a class-based configuration like so:

If I’m using the file like this, then I’ll end up with both pylint and pyflakes complaining that settings is unused, although it actually is (when the file gets imported and parsed). You can silence pylint by placing a comment on the import line (or in a pylintrc file to have…read more

Decent image loader widget in django

Posted by in Software

I’m working on a website where I need to be able to load an image. The default widget is abysmal; it has a url to the current image, a checkbox and a file loader input element. Even styled, it looks pretty bad. So, I’ve taken upon myself to prettify it and get from this: to this: To accomplish the transformation, we need: Crispy forms – just because my app uses it and it gives nice bootstrap-based formatting Floppy forms – because it allow us to customise widgets markusslima’s bootstrap-filestyle –…read more

Speed-up easy-thumbnails on S3

Posted by in Software

I was developing a small app as a playground and confidence builder, choosing django, heroku and S3 as resources. One of the packages used is easy-thumbnails. Behaviour I chose to use the easy-thumbnails app with S3, a possibility granted by the storages framework. At a glance, everything works OK; thumbnails are created and rendered accordingly. However, on a thumbnail-heavy page, I (and my profiling app) noticed significant load times (3s for a page with 7 thumbnails). Drilling down, it became evident that something was checking the S3 bucket for each…read more

Improve S3Boto Django-Storages Performance with Custom Settings

Posted by in Software

Django-storages is a great piece of software. It provides an uniform API for all kind of file storage backends, including Amazon’s S3. I use it for storing assets (the /static/ and /media/) for my django app. However, particularly with the /static/ assets, I’ve noticed firebug/yslow complaining of performance, so I’ve decided to dig in more into settings. First, there are some nice articles to help you deciding what you need to improve performance (you can find even more with a simple search). These provided some hints where to start from….read more

Deploy django application with private dependencies on dotcloud

Posted by in Software

Update: This is an outdated entry. DotCloud went to cloudControl, which joined ExoScale These days I’m trying to deploy an application on a something quicker than my shared host ( Not that there’s anything wrong with this provider (this blog is on it), but the latency is a bit too much (2 seconds is too much for a first-time visitor to wait). I tried to play with heroku (mainly because everyone in the cloud hosting world mentions it…), but I have a feeling that to do some decent testing I’ll…read more