Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Krystofee opened this issue Jan 17, 2018 · 0 comments

Comments

@Krystofee
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant