Skip to content

Changing position and collection foreign key simlutaneously does not work #56

Open
@Krystofee

Description

@Krystofee

models.py

class Item(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
    container = models.ForeignKey(to=Container)
    position = PositionField(collection='container')

class Container(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
    ...

django shell:

>>> container1 = Container.objects.create(...)
>>> item1 = Item.objects.create(container=container1)
>>> item2 = Item.objects.create(container=container1)
>>> container2 = Container.objects.create(...)
>>> item1.container = container2
>>> item1.position = 1

I've tried to debug the code and figured out that:

in fields.py (229 - update_on_save)

        current, updated = getattr(instance, self.get_cache_name())

the value of current is None and it gets compared to the int and I'm getting an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions