On 9 touko, 19:28, Gavin Wahl <[email protected]> wrote:
> I'd like to have a go at fixing this bug, but I'm not sure where to start.
> The problem seems to be that there's only a single instance of the field
> per model, so field.model is always the abstract class. I can't see a way
> to access the concrete class from the field instance. If the field only has
> a reference to the abstract model, which doesn't have a pk, how can it
> calculate join columns for the concrete model?

It can't. The field's model should be the concrete model, but due to
buggy field setup it isn't.

I took a look at altering the way virtual fields are copied from
abstract model to concrete model, but didn't find any easy solution
there. I didn't use too much time investigating this path, so taking
one more look might yield something. Start from
django.db.models.base:ModelBase.__new__() and virtual_fields copying.
Try to somehow end up in a situation where the field's model is the
concrete model.

More likely the solution is going to be found by altering how
GenericRelations are seen by the ORM. Before #19385 GenericRelation
masqueraded as m2m field (which it isn't), now in master it is a
ForeignObject subclass. The basic problem is that generic relation
represents reverse join, while ForeignObject usually represents direct
join. Doing changes in this area is likely going to be somewhat
complex...

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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].
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to