javascript - Django dynamically generated form sets. Deleted forms throwing validation error -


i have inline formset created inlineformset_factory. here simplified example.

#models.py class mymodel(models.model):     owner = models.foreignkey(user)     job_type = models.foreignkey(jobtype)     price = models.integerfield() class meta:     unique_together = (('owner', 'job_type'),)  #forms.py formset = inlineformset_factory(user, mymodel, fields=('job_type', 'price')) 

i using javascript dynamically add forms , delete forms formset. when click delete form hidden. i'm submitting forms ajax , sending errors if necessary.

this works fine except 1 detail. mymodel has unique condition. if deletes preexisting form (so hidden) , adds form same job_type , submits, django throws uniqueness validation error though 1 of forms being deleted.

i thought fix clearing job_type field on deleted form throws 'this field required' error , still throws uniqueness error.

any appreciated!

update

further research reveals error present in admin interface well. if include inline uniqueness condition model , try , delete , create inline object same values, throws uniqueness error. guess feature of django's formset validation. although i'm not sure advantage of behaviour maybe bug. more obvious whats going on when deleted forms aren't hidden though.

still, on getting round appreciated.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -