Merge branch 'master' of https://github.com/litchfield/django-multiselectfield into get_display
Conflicts: multiselectfield/db/fields.py
This commit is contained in:
commit
feb36f8fce
|
@ -90,5 +90,5 @@ a readily setup project that uses django-multiselectfield. You can run it as usu
|
|||
::
|
||||
|
||||
python manage.py syncdb --noinput
|
||||
python manage.py loaddata data
|
||||
python manage.py loaddata app_data
|
||||
python manage.py runserver
|
||||
|
|
|
@ -107,7 +107,7 @@ class MultiSelectField(models.CharField):
|
|||
def contribute_to_class(self, cls, name):
|
||||
super(MultiSelectField, self).contribute_to_class(cls, name)
|
||||
if self.choices:
|
||||
def get_display(obj):
|
||||
def get_list(obj):
|
||||
fieldname = name
|
||||
choicedict = dict(self.choices)
|
||||
display = []
|
||||
|
@ -120,7 +120,12 @@ class MultiSelectField(models.CharField):
|
|||
except (ValueError, TypeError):
|
||||
item_display = value
|
||||
display.append(string_type(item_display))
|
||||
return ", ".join(display)
|
||||
return display
|
||||
|
||||
def get_display(obj):
|
||||
return ", ".join(get_list(obj))
|
||||
|
||||
setattr(cls, 'get_%s_list' % self.name, get_list)
|
||||
setattr(cls, 'get_%s_display' % self.name, get_display)
|
||||
|
||||
MultiSelectField = add_metaclass(models.SubfieldBase)(MultiSelectField)
|
||||
|
|
Loading…
Reference in New Issue