MultipleChoiceCommaField - CheckboxSelectMultiple value sequence as a single string, comma-separated.
Since I frequently want to store multiple-selected choice items as a single field in the model, I found it convenient to write a custom field class. The code uses the comma as a separator, but it could be easily generalized to use any delimiter.
This view will enable you to generate OpenOffice documents from templates written in OpenOffice 2.x
Just make sure that there is no OO tag in between your code (no change in formatting etc.). content.xml is a valid XML file, so you can do some preprocessing using xml.dom.minidom. I would also recommend caching (just save the zip file without content.xml and content.xml on its own).
How to use it
{% pycall os.path.abspath(".") %}
{% pycall os.path.abspath(".") as path %}
This is the {{ path }}.
Syntax
{% pycall module.function(...) [as variable_name] %}
If there is no as variable_name, the result will be output directly.
As you can see, if you using django-rest-framework, you will found many different response format. This middleware to solve all of these problems with Standard API Response.
All HTTP Response status stored into json response, not in HTTP Status (because mobile application, like android can't fetch the response body when HTTP Status >= 400).
Makes it possible to add a filtering condition directly after the aggregate function (or possible, `aggregate(expression) WITHIN GROUP (ordering clause)`. This is mostly useful if the annotation has two or more expressions, so it's possible to compare the result with and without the applied filter; it's more compact than using `Case`. It's suggested to add `values` to the queryset to get a proper group by.
Usage example:
`books = Book.objects.values('publisher__name').annotate(
count=Count('*'),
filtercount=Filter(expression=Count('publisher__name'),
condition=Q(rating__gte=5))
)
`
Supported on Postgresql 9.4+. Possible other third-party backends.
Fields that support HTML optgroups. Adapted from [this snippet](https://djangosnippets.org/snippets/1968/) and updated to work with latest version of Django (1.9) and additional ModelMultipleChoiceField support added.
Example Usage:
tag = GroupedModelChoiceField(queryset=Tag.objects.all(), group_by_field='parent')
positions = GroupedModelMultiChoiceField(queryset=Position.objects.all(),
group_by_field='agency')
I've reimplemented the code I found somewhere on the web within my models file. The earlier version was incapable of converting all formats to JPG while this code converts all formats and compresses all of them successfully.
You need to have PILLOW installed for this to work.
A widget for a checkbox multi select, adapted from the RadioSelect widget, which allows you to iterate over each choice in the template rather than outputting the whole thing as a ul in one go.
{{ form.field.label_tag }}
{% for option in form.field %}
<span>{{ option }}</span>
{% endfor %}
A *SimpleListFilter* derived class that can be used to filter by taggit tags in the admin.
To use, simply add this class to the *list_filter* attribute of your ModelAdmin class.
Ex.:
class ItemAdmin(admin.ModelAdmin):
list_display = ('name', 'unit', 'amount')
list_filter = ('unit', TaggitListFilter)
Based in [ModelAdmin.list_filter documentation](https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter).
You're looking at the top-rated snippets currently on the site; if you'd like to contribute, sign up for an account and you'll be able to rate any snippet you see.