django_polymorphic
                                
                                 django_polymorphic copied to clipboard
                                
                                    django_polymorphic copied to clipboard
                            
                            
                            
                        Polymophic primary key as OneToOneField
Is it possible to use a OneToOneField as primary key in a PolymorphicModel? For example, take a look to the following snippet: class Food(models.Model): id = models.AutoField(primary_key=True)
class PreparedFood(PolymorphicModel): id = models.OneToOneField(Food, primary_key=True)
If we register the models to the admin interface, they will result in an exception:
- Caught AttributeError while rendering: type object 'PreparedFood' has no attribute 'polymorphic_primary_key_name'
I think the "problem" reside in polymorphic.base.py:82
    for f in new_class._meta.fields:
        if f.primary_key and type(f)!=models.OneToOneField:
            new_class.polymorphic_primary_key_name=f.name
            break
Apparently if the primary_key is a OneToOneField the polymorphic_primary_key_name is not defined.
What is the reason behind the type(f)!=models.OneToOneField check?
Thank you.
Edit: On closer inspection what vrde said.