Closed jnm closed 8 years ago
In addition, if you are using update_fields, Django will throw an error (ValueError: Cannot use None as a query value) if the position field isn't included in the list of fields. Version 0.4.6 did not have this issue.
class UpdateForm(ModelForm):
name = forms.CharField()
def save(self, commit=True):
instance = super(UpdateForm, self).save(commit=False)
if commit:
instance.save(update_fields=['name'])
return instance
class Meta:
model = Item
fields = ('name',)
To be clear, even if update_fields contains the position field (i.e. update_fields=['name','position']), the same behavior of moving to the last position is observed.
Hello! How about this issue? I had the same question.
Thanks!
D
I've verified that this is an issue, but haven't had time to get a fix together. It's probably obvious from how long this issue has been open, but I don't have much time to dedicate to this project at present. I'd be thrilled to merge the changes if anyone else has the resources to put together a pull request.
@jnm @chriskief do you guys have any workarounds for this?
@jpadilla, I don't have anything good—I've just kept using version 0.5.0, which doesn't have the bug.
@jnm will try downgrading mine to 0.5.0 as well, thanks!
@jpadilla I've been using the previous version as well.
Same here. The last object saved gets the last position and all numbers being rebuilt. I didn't have time to look at it. Did anyone of those using django-position
managed to solve the issue?
Update, solved in my fork. See the related pull request.
Hello,
After upgrading to 0.5.1, I noticed that when an object is saved via a
ModelForm
that does not include a position field, that object's position moves to last place. I think this is the responsible change: https://github.com/jpwatts/django-positions/commit/cfdb4847757a9d59caf026c0df95a451f292d67b#diff-d225dfacb4effdf5497b014c35da0d4eR92I created a minimal project to demonstrate the issue using the models in the "photo" example. It's housed at https://github.com/jnm/django-positions-test, and the ModelForm I use there is: