I'm having trouble understanding the problem. Could you give some example 
models and code that demonstrates it?

On Tuesday, December 8, 2015 at 8:10:51 AM UTC-5, martin f krafft wrote:
>
> Hello, 
>
> I hope this is the right place to bring up the following idea, even 
> if it's in django.contrib.contenttypes. 
>
> GenericForeignKeys currently hard-require a model to have 
> a ForeignKey field to the ContentType model. In a specific use-case, 
> we're experiencing a bit of trouble with this, because the 
> ContentType in our case is actually indirectly available via another 
> ForeignKey: 
>
>   MyModel → n:1 → ParentModel → n:1 → ContentType 
>
> However, contenttypes cannot be convinced to access the extra level 
> of indirection and complains that MyModel.ForeignKey('ParentModel') 
> is not a ForeignKey('ContentType'). 
>
> Despite the additional query overhead, it'd be great if instead 
> I could tell contenttypes that it should 
>
>   either 
>   (a) look beyond the current model for the actual content_type 
>       attribute, e.g. content_type='myattribute.content_type', 
>       which, if myattribute is a ForeignKey itself adds a level of 
>       indirection but doesn't change the logic and causes 
>       contenttypes to resolve myattribute and use the content_type 
>       field on the result, 
>
>   or 
>   (b) avoid hard-coding the dependency on ContentType and instead 
>       duck-type the argument, such that my parent model could expose 
>       the necessary functionality, e.g. via proxy calls to the 
>       ForeignKey on ContentType stored in the parent. 
>
> Does this make sense? Would it be worthwhile to start working on 
> a patch for this? Which of (a) or (b) would be preferred? It feels 
> to me that while (b) is the Pythonesque way, (a) is more Django… 
>
> Looking forward to your thoughts, 
>
> -- 
> @martinkrafft | http://madduck.net/ | http://two.sentenc.es/ 
>   
> warning: dates in calendar are closer than they appear. 
>   
> spamtraps: [email protected] <javascript:> 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/934950d5-f51e-46f0-ad71-3ef4151ed8bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to