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.
This is in my opinion a better way to have flat pages in a project. In the example with the url patterns settings: / will render -> /pages/welcome.html /contact will render -> /pages/contact.html /products/ will render -> /pages/products/index.html /products/pricing will render -> /pages/products/pricing.html
Function and usage in views and template with django-paypal to have encrypted paypal buttons with a cart(adding multiple elements). All credits go to Jon Atkinson, http://jonatkinson.co.uk/paypal-encrypted-buttons-django/ I just added it here with a complete implementation using a cart(his example didnt include it). I know there is some redundancy in the data passed to the dict and the submit form, i'm just not sure what can i take out, the paypal docs are not clear about it, if you test this code without some of the data and it works, please tell me. The key parts are the cmd _s-xclick and again the cmd '_cart' both are needed.
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
If you read the docstring and the example you should get a clue what this Code does. I didn't want a big function everytime that handles every specific form, formset combinations so this how i can add/edit Models with specific Forms given to the magic_handle_inlineformsets function. It also works for Forms without innline_formsets.
This custom test suite runner will record all of the URLs accessed during your test suite. It will compare it to the list of all URLs you have configured for your site and produce a report of any URLs missed. It requires that all URLs are named (using the ``name=`` parameter). To use is, set the ``TEST_RUNNER`` variable in your configuration to this class. You can also define ignored URLs. For example, to filter out the admin URLs, you can use: IGNORED_COVERAGE_URLS = ['^admin/', '^admin/doc/']
This code is for set one register on admin if exist more than 1 register you can not delete it or add more. Only set mymodel
CitySelector is a jquery widget, allowing to pick cities from DB, filled by django_ipgeobase application. Also it includes widget for django forms, based on mentioned jquery plugin, views and urlconf, required to provide interaction between widget and DB and middleware, populating request with correspondent location. Visit https://bitbucket.org/JustDelight/city_selector
Management command to update a primary key and update all child-tables with a foreign key to this table.
3110 snippets posted so far.