Changes between Version 2 and Version 3 of Ticket #24858


Ignore:
Timestamp:
May 27, 2015, 2:23:43 AM (9 years ago)
Author:
Mounir
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24858 – Description

    v2 v3  
    1717    )
    1818
    19     example = Example.objects.create(multi_choices_array= [1, 2])
    20     example.get_multi_choices_array_display()
    21     # Will raise a Type Error exception
     19    # Adding this method will show the values
     20    def multi_choices_array_display(self):
     21        result = ''
     22        choices = dict(self.CHOICES)
     23        for index, value in enumerate(self.multi_choices_array):
     24            result += "{0}".format(choices[value])
     25            if not index == len(self.multi_choices_array) - 1:
     26                result += ', '
     27        return result
     28
     29example = Example.objects.create(multi_choices_array= [1, 2])
     30example.get_multi_choices_array_display()
     31# Will raise a Type Error exception
     32example.multi_choices_array_display()
     33# Will print 'value1, value2'
    2234
    2335}}}
Back to Top