#25129: Migration crash on ForeignKey with a callable default that returns a 
model
instance
----------------------------+------------------------------------
     Reporter:  timgraham   |                    Owner:  nobody
         Type:  Bug         |                   Status:  new
    Component:  Migrations  |                  Version:  1.8
     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 charettes):

 Since no arguments are passed to the default value callable we've got two
 options:

 1. Document that foreign key callable defaults must return the value of
 the field they reference (`pk` unless `to_field` is set).
 2. Change the check in `ForeignKey.get_default()` to
 `instance(field_default, models.Model) and field_default._meta.label ==
 self.remote_field.model._meta.label`.

 I'd favor the first option.

--
Ticket URL: <https://code.djangoproject.com/ticket/25129#comment:1>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.da1ab2e106372d2f46c586cdfda4a617%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to