Method is_valid of forms/formset.py::BaseFormSet should take in account
deleted children forms to prevent a wrong validation error.
{{{
#!div style="font-size: 80%"
Simple models.py:
{{{#!python
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')
}}}
}}}
{{{
#!div style="font-size: 80%"
Simple admin.py:
{{{#!python
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:
[[Image(unique-together-formset.png)]]
--
Ticket URL: <https://code.djangoproject.com/ticket/31932>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "unique-together-formset.png" added.
--
Ticket URL: <https://code.djangoproject.com/ticket/31932#comment:1>
* owner: nobody => anujpandey785
* status: new => assigned
Comment:
i would like to work on this.
--
Ticket URL: <https://code.djangoproject.com/ticket/31932#comment:2>
* owner: anujpandey785 => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/31932#comment:3>
* type: Bug => New feature
* stage: Unreviewed => Accepted
Comment:
Thanks for this ticket, this looks simpler then swapping unique values
(#25139) but it's also tricky because unique checking exists at the
database level. Tentatively accepted. Would you like to work on PoC?
--
Ticket URL: <https://code.djangoproject.com/ticket/31932#comment:4>
* owner: (none) => Aditya parashar
* status: new => assigned
Comment:
I think the solution may be use a clean method
--
Ticket URL: <https://code.djangoproject.com/ticket/31932#comment:5>
* owner: Aditya parashar => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/31932#comment:6>
* owner: (none) => waheedsys
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/31932#comment:7>
PR - https://github.com/django/django/pull/17822
--
Ticket URL: <https://code.djangoproject.com/ticket/31932#comment:8>