Snippet List
Custom form widget for rendering an autocomplete (using jQuery UI's autocomplete widget) text input in a template.
This arose from the need to have all fields asking for a state to use autocomplete, so I decided to make this.
- forms
- jquery
- autocomplete
- widget
- jqueryui
Overridden save() method that adds Gravatar support for a user with a profile photo field (and presumably an email field). Checks to see if user has provided a photo. If not, then query Gravatar for a possible photo. Finally, if Gravatar does not have an appropriate photo for this user, then use whatever default photo is available (in this case, 'users/photos/default_profile_photo.png'... change as necessary).
Will help you retrieve the value from a dictionary with a supplied key, or the human-readable value from a choices tuple. Works as follows:
To retrieve the value of a dict:
`{{ crime_rates_dict|getval:"Chicago" }}` <-- will return value of `crime_rates_dict["Chicago"]`
To retrieve the human-readable value from a choices tuple:
`{{ country.COUNTRIES|getval:"US" }}` <-- will return "United States" in `COUNTRIES = (("US", "United States"),)`
- template
- templatetag
- choices
- dict
- tuple
JoeLinux has posted 3 snippets.