Skip to content

Copying Polymorphic objects for ModelC not working #414

@pipanchik

Description

@pipanchik

From example:

from django.db import models
from polymorphic.models import PolymorphicModel

class ModelA(PolymorphicModel):
    field1 = models.CharField(max_length=10)

class ModelB(ModelA):
    field2 = models.CharField(max_length=10)

class ModelC(ModelB):
    field3 = models.CharField(max_length=10)

I set in object .id and the .pk of the object to None before saving:

>>> o = ModelB.objects.first()
>>> o.field1 = 'new val' # leave field2 unchanged
>>> o.pk = None
>>> o.id = None
>>> o.save()

It works.
But this method does not work if i coping ModelC (because modela_ptr not set to None).

What should I do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions