Tag Archives: django

[django] Creating dynamic lists of radio buttons from arbitrary classes and with long descriptions

I was looking for a way to put a lot of text next to the radio buttons in a django form. I also needed the list of radio buttons to automatically populate and vary according to the situation. After the … Continue reading

Posted in geek | Tagged | Leave a comment

Is there a Django template tag that lets me set a context variable?

The answer is buried inside the more complex current_time example in the documentation. Problem You want to add a variable to the context. But you don’t want to go back and add that variable to all the views which call … Continue reading

Posted in geek | Tagged | Leave a comment

Django widget renderer render

I got a little frustrated trying to find the ‘simple’ answer to change the html which is generated by the various form field widgets. In this case the RadioSelect field generates radio buttons wrapped in an unordered list. It was … Continue reading

Posted in geek | Tagged | 1 Comment

[Django] How to replace an image using ModelForm

I have a user profile model which holds their ‘mugshot’ image. I’m using modelForm to to present a profile update form. It was easy to build a working form, but now I need a couple of tweaks to the image: … Continue reading

Posted in geek | Tagged | Leave a comment

Date formats and Django forms

Date formats are something that US dominance remains unable to overcome. Whilst all software assumes a format of mm/dd/yyyy, all other nations of the world want to change that to their local preference. Django is no exception. Here’s the magic … Continue reading

Posted in geek | Tagged | Leave a comment

Age in years with python?

Given someone’s date of birth how do I work out their age? This is actually less trivial than first appears because: the person’s age doesn’t increment until their birthday passes on the calendar that day is not always the same … Continue reading

Posted in geek | Tagged , | 2 Comments