#29283: Difference between 'apps.get_model' and 'import' in migration
-------------------------------------+-------------------------------------
     Reporter:  bronvic              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.11
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Hello there,

 Without going into all the details you can't mix migration defined models
 with application defined ones. When writing `RunPython` executors you must
 '''always''' use the provided `apps.get_model` method to retrieve models.
 In your particular case `get_user_model()` is going to return an
 application defined model class and not a migration one; you should use
 `apps.get_model(settings.AUTH_USER_MODEL)` instead.

 In there future please avoid using this ticket tracker as a support
 channel TicketClosingReasons/UseSupportChannels.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29283#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/065.372c5d5c6595e65b9e4b405d98b4d6fd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to