Template filter to get each attribute value in an iterable
Iterate through the supplied iterable and return the `attrname` eattribute of each element in the iterable. Useful with the `join` filter
- filter
 - iterable
 
Iterate through the supplied iterable and return the `attrname` eattribute of each element in the iterable. Useful with the `join` filter
This snippet is based on [#1051](http://djangosnippets.org/snippets/1051/). It adds filtering by existence of at least one related object. It is an example of how to simply subclass the FilterSpec class, in order to build a custom Filter. The comment in the code contains instructions on how to implement it in a real project.
A simple 2-tuple list of time zones for use in a choice field or select box for Django, or wherever needed.
Check email and save
view/admin.py ` def reactor(request): context = { 'email': read_mailbox() } return render_to_response(_lookup_template('dashboard'), context, context_instance=RequestContext(request)) ` **_Design all.js** ` function (doc) { if (doc.doc_type == 'MailArchive') { emit(doc._id, doc); } } ` **reduce.js** `_count`
This is the code we use on bandtastic.me to build a html that sends users to dineromail to pay with. This code builds a form thats ready to send multiple items.
I use this snippet to save images to my imagefields on django models. This uses the very awesome requests library, so install it first pip install requests You probably want to have this be done on a celery queu, if the image is big enough.
The problem with Django's default Radio button widget is that it puts the buttons in a vertical format and the documentation is somewhat silent on how to make them horizontal. If you are dealing with a long list of buttons then veritical is probably the way to go but if you are dealing with "YES/NO" situation or any other boolean choice then you will probably want them horizontal. Basically I just took the code and even the explanation from here: https://wikis.utexas.edu/display/~bm6432/Django-Modifying+RadioSelect+Widget+to+have+horizontal+buttons
This function downloads selected rows to CSV file. The snippet is based on snippet 1697 and 2020. This function downloads all columns given in the list_display, including callable items.
Whoops just an alternative implementation of UpdateView
You only have to put the code in some of your models.py and to have django-fiber installed in your system. Every image uploaded using Fiber admin dialog will be automatically resized and thumbnailed. Or whatever you need to do with it.
Updating fields that allow for NULLs must take care about those NULLs. Use case: `Message.objects.filter(id=1).update(price=CF('price', 0) + 7)` `Message.objects.filter(id=1).update(status=CF('status') // 's')` Works for postgres. Supposedly works for mysql. Didn't test with other backends.
Call resize_image to replace the image with a resized and normalized version of itself. I recommend doing this with celery, but you could also hook it up to the admin interface if you're not impatient.
Dependencies: urllib, simplejson
You'll need to `pip install pyScss` first. Converts on the fly, so you won't want to use this for much more than just testing. Usage in a template: {% load sass %} {% include_sass "disclosures/css/base.scss" %} {% include_sass "disclosures/css/grid.scss" %}