Viewing posts for the category Django

Print CGI / META /QUERY_STRING in Django Template

Posted by: scoopseven in Django 13 years ago
Differentiating how to display or access variables/structures/dictionaries in Django templates (as opposed to views) can get frustrating. All I was trying to do was print the query string in a template. That's. It. Why couldn't I just do:

read more / 0 comments

Unpacking a Tuple in a Django Template

Posted by: scoopseven in Django 13 years ago
You've passed in a tuple to your template and now you're trying to access the separate indexes/items in a loop. Here's the tuple:

read more / 0 comments

Multiple Form Fields with the Same Name / Form Field Value as a List in Django

Posted by: scoopseven in Django Python 13 years ago
I encountered a scenario where I have a list that I needed to pass over in a form, something like:

read more / 0 comments

Display Tuple Value for Choices Field in Django

Posted by: scoopseven in Django 13 years ago
I know, this is an odd name for a post. I'm trying to explain this:

read more / 0 comments

Sort Python Dictionaries by Key or Value

Posted by: scoopseven in Django Python 13 years, 1 month ago
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

Recent Tweets

Recent Posts

Archive

2013
2012
2011
2010
2009
2008
2007
2006

Categories

Authors

Feeds

RSS / Atom