#34716: Class methods from nested classes cannot be used as Field.default.
---------------------------------+------------------------------------
     Reporter:  Nicolò Intrieri  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Migrations       |                  Version:  4.2
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by Nicolò Intrieri):

 Replying to [comment:1 Mariusz Felisiak]:
 > Thanks for the report. It seems that `FunctionTypeSerializer` should use
 `__qualname__` instead of `__name__`:
 > {{{#!diff
 > diff --git a/django/db/migrations/serializer.py
 b/django/db/migrations/serializer.py
 > index d88cda6e20..06657ebaab 100644
 > --- a/django/db/migrations/serializer.py
 > +++ b/django/db/migrations/serializer.py
 > @@ -168,7 +168,7 @@ class FunctionTypeSerializer(BaseSerializer):
 >          ):
 >              klass = self.value.__self__
 >              module = klass.__module__
 > -            return "%s.%s.%s" % (module, klass.__name__,
 self.value.__name__), {
 > +            return "%s.%s.%s" % (module, klass.__qualname__,
 self.value.__name__), {
 >                  "import %s" % module
 >              }
 >          # Further error checking
 >
 > }}}
 >
 > Would you like to prepare a patch? (regression test is required)

 I would be very happy to prepare a patch, i will do my best to write a
 test that's coherent with the current suite

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34716#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018963ef7fc0-924ad0b6-a776-4061-8287-83e0242a4c15-000000%40eu-central-1.amazonses.com.

Reply via email to