djangosnippets.org: Latest snippets tagged with 'ManyToManyField'https://djangosnippets.org/tags/manytomanyfield_1/2014-06-25T06:40:08.157161-05:00Admin action for a "CSV Export" with ManyToManyField
2014-06-25T06:40:08.157161-05:00CarlosRodriguezhttps://djangosnippets.org/snippets/3076/<p>Based on <a href="https://djangosnippets.org/snippets/2369/">#2369</a></p>
<p>Save the snippet as actions.py within your django app, and then add an action on any model you want in it's ModelAdmin definition.</p>
<p>Example usage:</p>
<pre><code>from actions import export_as_csv_action
class YourModelAdmin(admin.ModelAdmin):
list_display = (...)
list_filter = [...]
actions = [export_as_csv_action("CSV Export", fields=[...])]
</code></pre>
Freely redistributableRelatedNullFilterSpec: django-admin custom filter all/null/not null/choices
2010-10-07T14:30:59.132524-05:00Codekohttps://djangosnippets.org/snippets/2229/<p>A simple django-admin filter to replace standar RelatedFilterSpec with one with the "All"/"Null"/"Not null" options.
It applies to all relational fields (ForeignKey, ManyToManyField).
</p>
<p>You can put the code in the <code>__init__.py</code> or wherever you want.
</p>
<p>The <code>_register_front</code> idea is copied on <a href="http://djangosnippets.org/snippets/1963/">this snippet</a>
</p>
Freely redistributableLink raw_id_fields (both ForeignKeys and ManyToManyFields) to their change pages
2010-10-04T09:44:54.322975-05:00EmilStenstromhttps://djangosnippets.org/snippets/2217/<p><strong>UPDATE: Now works in Django 1.4</strong></p>
<p>Based on luc_j:s snippet (http://djangosnippets.org/snippets/2108/) to show values in ManyToManyFields in the admin. This snippets does that, but also links each value to its corresponding admin change page.</p>
<p>To use, just set the raw_id_fields to the value you want, and let your form inherit …</p>
Freely redistributableDisplay user-friendly values of a ManyToManyRawIdWidget
2010-07-15T00:34:28.231746-05:00luc_jhttps://djangosnippets.org/snippets/2108/<p>A Widget for displaying ManyToMany ids in the "raw_id" interface rather than in a <select multiple> box. Display user-friendly value like the ForeignKeyRawId widget</p>
Freely redistributable