Ticket #12340: generic_inline_order_qs_v1.diff

File generic_inline_order_qs_v1.diff, 882 bytes (added by jbronn, 15 years ago)

Orders the queryset.

  • django/contrib/contenttypes/generic.py

     
    317317        from django.contrib.contenttypes.models import ContentType
    318318        if self.instance is None or self.instance.pk is None:
    319319            return self.model._default_manager.none()
    320         return self.model._default_manager.filter(**{
     320        qs = self.model._default_manager.filter(**{
    321321            self.ct_field.name: ContentType.objects.get_for_model(self.instance),
    322322            self.ct_fk_field.name: self.instance.pk,
    323323        })
     324        if not qs.ordered:
     325            qs = qs.order_by(self.model._meta.pk.name)
     326        return qs
    324327
    325328    def save_new(self, form, commit=True):
    326329        # Avoid a circular import.
Back to Top