#8309: GenericForeignKey fails when used in abstract base models
-----------------------------------+----------------------------------------
          Reporter:  Wonlay        |         Owner:  msaelices                  
          
            Status:  assigned      |     Milestone:  1.0                        
          
         Component:  Contrib apps  |       Version:  SVN                        
          
        Resolution:                |      Keywords:  GenericForeignKey , model 
inheritance
             Stage:  Accepted      |     Has_patch:  0                          
          
        Needs_docs:  0             |   Needs_tests:  0                          
          
Needs_better_patch:  0             |  
-----------------------------------+----------------------------------------
Comment (by msaelices):

 Real problem is in this fragment of {{{django.db.base.ModelBase}}} class:
 {{{
                 # The abstract base class case.
                 names = set([f.name for f in new_class._meta.local_fields
 + new_class._meta.many_to_many])
                 for field in base._meta.local_fields +
 base._meta.local_many_to_many:
                     if field.name in names:
                         raise FieldError('Local field %r in class %r
 clashes with field of similar name from abstract base class %r'
                                 % (field.name, name, base.__name__))
                     new_class.add_to_class(field.name,
 copy.deepcopy(field))
 }}}

 The problem is
 {{{django.contrib.generic.GenericForeignKey.contribute_to_class}}} doesnt
 call to {{{cls._meta.add_field(self)}}}, that insert field into
 {{{base._meta.local_fields}}}.

 But the thing is {{{GenericForeignKey}}} is not a real field... is a
 virtual field. I'll try take a workaround that also implements a new
 feature, for adding virtual fields thats follow inheritance.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8309#comment:8>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to