Unique checking in formsets should exclude forms marked for deletion.
Validation of a formset with a unique_together doesn't take deleted children into account.
Method is_valid of forms/formset.py::BaseFormSet should take in account deleted children forms to prevent a wrong validation error.
Simple models.py:
from django.db import models
from django.utils.translation import ugettext as _
class Book(models.Model):
title = models.CharField(max_length=64, verbose_name=_("Title"))
class Language(models.Model):
language = models.CharField(max_length=64, verbose_name=_("Language"))
class Translator(models.Model):
name = models.CharField(max_length=64, verbose_name=_("Name"))
book = models.ForeignKey(Book, on_delete=models.CASCADE)
language = models.ForeignKey(Language, on_delete=models.CASCADE)
class Meta:
unique_together = ('book', 'language')
Simple admin.py:
from django.contrib import admin
from .models import Book, Language, Translator
class TranslatorInline(admin.TabularInline):
model = Translator
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
inlines = [TranslatorInline]
@admin.register(Language)
class LanguageAdmin(admin.ModelAdmin):
pass
Wrong validation error:

Change History
(11)
Summary: |
unique_together with a formset prompt a wrong validation → unique_together with a formset prompts a wrong validation
|
Owner: |
changed from nobody to anujpandey785
|
Status: |
new → assigned
|
Owner: |
anujpandey785 removed
|
Status: |
assigned → new
|
Summary: |
unique_together with a formset prompts a wrong validation → Unique checking in formsets should exclude forms marked for deletion.
|
Triage Stage: |
Unreviewed → Accepted
|
Type: |
Bug → New feature
|
Owner: |
set to Aditya parashar
|
Status: |
new → assigned
|
Owner: |
Aditya parashar removed
|
Status: |
assigned → new
|
Owner: |
set to syed waheed
|
Status: |
new → assigned
|
Patch needs improvement: |
set
|
i would like to work on this.