Ticket #2463: related.diff

File related.diff, 1.0 KB (added by nesh <nesh [at] studioquattro [dot] co [dot] yu>, 18 years ago)

quick fix

  • store/django/django/db/models/fields/__init__.py

     
    289289        if self.choices:
    290290            return first_choice + list(self.choices)
    291291        rel_model = self.rel.to
    292         return first_choice + [(getattr(x, self.rel.get_related_field().attname), str(x))
    293                                for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)]
     292        lst = []
     293        for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to):
     294            if hasattr(self.rel, 'get_related_field'):
     295                lst.append((getattr(x, self.rel.get_related_field().attname), str(x)))
     296            else:
     297                lst.append((x._get_pk_val(), str(x)))
     298        return first_choice + lst
    294299
    295300    def get_choices_default(self):
    296301        if self.radio_admin:
Back to Top