Login

Tag "ManyToManyField"

Snippet List

Admin action for a "CSV Export" with ManyToManyField

Based on [#2369](https://djangosnippets.org/snippets/2369/) 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. Example usage: from actions import export_as_csv_action class YourModelAdmin(admin.ModelAdmin): list_display = (...) list_filter = [...] actions = [export_as_csv_action("CSV Export", fields=[...])]

  • ManyToManyField
  • Adminactions
  • ManyToManyFields
  • Export-CSV
  • Adminaction
  • CSV
  • Export
  • ManyToMany
  • Many-to-many
Read More

RelatedNullFilterSpec: django-admin custom filter all/null/not null/choices

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). You can put the code in the `__init__.py` or wherever you want. The `_register_front` idea is copied on [this snippet](http://djangosnippets.org/snippets/1963/)

  • filter
  • admin
  • null
  • filterspec
  • ManyToManyField
  • ForeignKey
  • not-null
Read More

Link raw_id_fields (both ForeignKeys and ManyToManyFields) to their change pages

**UPDATE: Now works in Django 1.4** 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. To use, just set the raw_id_fields to the value you want, and let your form inherit from ImproveRawIdFieldsForm.

  • admin
  • widget
  • django-admin
  • raw_id_fields
  • ManyToManyField
  • ForeignKey
Read More

4 snippets posted so far.