sehmaschine/django-grappelli — Issue #65: Inline sortables - adds position index to untouched inline forms on save
Author: bashmish
Created: 2011-12-14 22:23:31+00:00
State: open

If you have an inline form for model that has a select widget with default state (for example, models.NullBooleanField has a default stat of "Unknown") then Grappeli thinks that this form was edited and adds index to position input on save in all forms even if they were not touched/edited. Then Django thinks that inline formset contains additional forms with only position and select widget inputs edited. Of course these additional forms are wrong and must be all blank.

My particular case is

# models.py

class Site(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
url = models.URLField(u'URL')
is_official = models.NullBooleanField()
position = models.IntegerField()

# admin.py

class SiteInline(generic.GenericTabularInline):
model = Site
extra = 5
ordering = ('position',)
sortable_field_name = 'position'
verbose_name = Site._meta.verbose_name
verbose_name_plural = Site._meta.verbose_name_plural