Ticket #21288: generic-E126.diff

File generic-E126.diff, 1.6 KB (added by alasdair, 18 months ago)

PEP8 cleanup of contrib.contenttypes.generic.py

  • django/contrib/contenttypes/generic.py

    diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
    index bffd969..82e657d 100644
    a b class GenericRelation(ForeignObject): 
    240240
    241241        """
    242242        return self.rel.to._base_manager.db_manager(using).filter(**{
    243                 "%s__pk" % self.content_type_field_name:
    244                     ContentType.objects.db_manager(using).get_for_model(
    245                         self.model, for_concrete_model=self.for_concrete_model).pk,
    246                 "%s__in" % self.object_id_field_name:
    247                     [obj.pk for obj in objs]
    248                 })
     243            "%s__pk" % self.content_type_field_name:
     244            ContentType.objects.db_manager(using).get_for_model(
     245                self.model, for_concrete_model=self.for_concrete_model).pk,
     246            "%s__in" % self.object_id_field_name:
     247            [obj.pk for obj in objs]
     248        })
    249249
    250250
    251251class ReverseGenericRelatedObjectsDescriptor(object):
    def create_generic_related_manager(superclass): 
    353353            query = {
    354354                '%s__pk' % self.content_type_field_name: self.content_type.id,
    355355                '%s__in' % self.object_id_field_name:
    356                     set(obj._get_pk_val() for obj in instances)
     356                set(obj._get_pk_val() for obj in instances)
    357357            }
    358358            qs = super(GenericRelatedObjectManager, self).get_queryset().using(db).filter(**query)
    359359            # We (possibly) need to convert object IDs to the type of the
Back to Top