Viewing posts for the category Python
I encountered a scenario where I have a list that I needed to pass over in a form, something like:
read more
/
0 comments
Dictionaries have no __order__ so when you're need to sort one, you're out of luck, right? Not so! Found
this goodness with instructions on sorting/ordering Python dictionaries by key or value. I needed to sort a dictionary of regions alphabetically to populate a ChoiceField/select/dropdown box.
read more
/
0 comments
If you're looking to add a empty_label to your ChoiceField, like you can for ModelChoiceField (empty_label="All"), you're going to have to override __init__ on your form. This solution I found on
StackOverflow works well.
read more
/
0 comments
I'm always doing this, so some of you must be too. I'll compare a date field in with a datetime object in Python/DJango like this:
read more
/
0 comments
Problems installing MySQLdb? Me too! I'm installing using MySQL 5 / Django 1.1 / Python 2.4 on CentOS 5.4 linux.
read more
/
0 comments