#33938: Defining the "through" model in a many-to-many field in another app 
causes
"AttributeError: 'str' object has no attribute '_meta'" on migration
-------------------------------------+-------------------------------------
     Reporter:  bryan.af7            |                    Owner:  Simon
                                     |  Charette
         Type:  Bug                  |                   Status:  assigned
    Component:  Migrations           |                  Version:  4.0
     Severity:  Normal               |               Resolution:
     Keywords:  migration many-to-   |             Triage Stage:  Accepted
  many bug                           |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * has_patch:  0 => 1


Comment:

 This is a regression in Django 4.0 caused by
 aa4acc164d1247c0de515c959f7b09648b57dc42,
 [https://github.com/django/django/pull/15973 this PR] should solve it.

 You can manually resolve the issue for your project by breaking the
 `fonte` migration generated on `makemigration` in two by moving the
 `variaveis` out of the `CreateModel` to an `AddField` operation that
 depends on the two others.

 This can be achieve with `makemigrations` with the following sequence of
 operation.

 1. Keep your models as they are defined now.
 2. Comment the `variaveis` definition.
 3. Run `makemigrations`
 4. Uncomment `variaveis`
 5. Run `makemigrations`
 6. Edit the latest migration for `fonte`, the one with the
 `AddField('FonteModel', 'variaveis', ...)`, to add an entry in
 `dependencies` that refers to the migration where
 `fonte_variavel.FonteVariavelModel` is defined when running step 3.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33938#comment:3>
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/01070182b751aeee-dabfcbc5-935c-4fc7-a2d3-1d5801587a07-000000%40eu-central-1.amazonses.com.

Reply via email to