Changes between Initial Version and Version 1 of Ticket #34716


Ignore:
Timestamp:
Jul 17, 2023, 5:01:57 AM (16 months ago)
Author:
Mariusz Felisiak
Comment:

Thanks for the report. It seems that FunctionTypeSerializer should use __qualname__ instead of __name__:

  • django/db/migrations/serializer.py

    diff --git a/django/db/migrations/serializer.py b/django/db/migrations/serializer.py
    index d88cda6e20..06657ebaab 100644
    a b class FunctionTypeSerializer(BaseSerializer):  
    168168        ):
    169169            klass = self.value.__self__
    170170            module = klass.__module__
    171             return "%s.%s.%s" % (module, klass.__name__, self.value.__name__), {
     171            return "%s.%s.%s" % (module, klass.__qualname__, self.value.__name__), {
    172172                "import %s" % module
    173173            }
    174174        # Further error checking

Would you like to prepare a patch? (regression test is required)

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34716

    • Property Triage Stage UnreviewedAccepted
    • Property Summary Using subclass method as a callable for a field's default value results in wrong reference in the corresponding migrationClass methods from subclasses cannot be used as Field.default.
  • Ticket #34716 – Description

    initial v1  
    1616            return [cls.BASIC]
    1717
    18         capabilities = ArrayField(
    19           models.CharField(choices=Capability.choices, max_length=30, blank=True),
    20           null=True,
    21           default=Capability.default
    22         )
     18    capabilities = ArrayField(
     19        models.CharField(choices=Capability.choices, max_length=30, blank=True),
     20        null=True,
     21        default=Capability.default
     22    )
    2323
    2424
Back to Top