#23624: Regression in ManyToManyField with through, runtime-generated models
-------------------------------------+-------------------------------------
     Reporter:  ludoo                |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by ludoo):

 Replying to [comment:5 bmispelon]:
 > I've bisected the error to this commit:
 9f13c3328199d2fa70235cdc63bb06b1efc5b117

 Fantastic. The commit points to the solution: a run-time generated models
 module does not belong to any app, so its models are not used to resolve
 complex relations.

 Creating an AppConfig instance at runtime with the correct name, and a
 module with a 'models' attribute pointing to the run-time generated models
 module is not enough though, as one also needs to do some of the stuff
 that gets done in the app registry's populate method when it's
 initialized. It's a few lines of code but it feels weird and unclean, it
 would be ideal if the apps registry had a way to register apps after it
 has been initialized.

 > Still not sure if this is a bug in Django or if your use-case is just
 not supported. It certainly looks weird.

 I admit the use-case is a bit specialized, but it's something that used to
 work in 1.6, and it can be easily made to work in 1.7 with the steps
 outlined above. The only problem I see is that finding *how* it works is
 almost impossible for a regular person (it took your involvement to
 pinpoint the correct commit, etc.). Having a way to register dynamically
 generated apps/models, and somewhere in the docs that states how to do it
 would be enough for the few people needing it, I guess.

 BTW, my use-case is the Wordpress multi-blog database (each blog has its
 own set of tables, etc), so it's probably a db design used in lots of
 other legacy databases.

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

Reply via email to