Skip to content

Instantly share code, notes, and snippets.

View metroid09's full-sized avatar

Chris Merkley metroid09

View GitHub Profile
@metroid09
metroid09 / multiple_select_field.py
Last active March 22, 2019 15:09 — forked from kottenator/multiple_select_field.py
Django's multiple-choice model field with static choices
"""
Field with multiple *static* choices (not via m2m)
Value is stored in DB as comma-separated values
Default widget is forms.CheckboxSelectMultiple
Python value: list of values
Original Django snippet: https://djangosnippets.org/snippets/1200/
It's 6 years old and doesn't work with latest Django
Also it implements 'max_choices' functionality - I have removed it for simplicity

Keybase proof

I hereby claim:

  • I am metroid09 on github.
  • I am thisismetroid (https://keybase.io/thisismetroid) on keybase.
  • I have a public key ASC6T31uo9K7x2kRXiD-pk_ycgQWHIRHXJ4QStwbu0JwSAo

To claim this, I am signing this object: