Bon dia Carles. I'm inclined to say that calling self.errors in __init__ is at least *holding it wrong*.
I'm not sure what if anything we might do about that. DRF's serializers have all kinds of "you have to call is_valid() before accessing .data" type assertions, but they only catch the obvious cases: we still get reports of unusual combinations not working on the tracker. So I think trying to enforce usage is probably a loosing battle. Without thinking about it, I don't know exactly where I'd add the field on the way out but coming in I'd look to see if allow_error was present in clean() https://docs.djangoproject.com/en/3.0/ref/forms/validation/#validating-fields-with-clean I hope that helps. Kind Regards, Carlton On Friday, 19 June 2020 13:39:00 UTC+2, Carles Pina Estany wrote: > > > Hi, > > Yesterday I found that calling self.errors in the constructor of a Form > that is in an InlineFormSet (or any formset I guess): the "delete" of a > form doesn't work anymore. I wonder if this is a bug in Django (for this > case, if a new bug is needed, I'm happy to open it... or be referred to > an existing bug) or if I missed some bit of the documentation. > > Summary: > BaseForm.errors does: > https://github.com/django/django/blob/master/django/forms/forms.py#L169 > > The DELETE field in self.fields is added in the form.fields via > BaseFormSet after calling the constructor of the form: > https://github.com/django/django/blob/master/django/forms/formsets.py#L175 > > So calling self.errors cleans the data but DELETE doesn't end up in > self.clean_fields (because it's not in self.fields). When DELETE is > added as a field self.clean_fields is not updated. > > (I'm talking about this: > https://github.com/django/django/blob/master/django/forms/formsets.py#L390 > being executed too late; or self.errors being called too early) > > The full story is here: > https://groups.google.com/forum/#!topic/django-users/wO9H0cNcLfI > > Thank you very much, > > -- > Carles Pina i Estany > https://carles.pina.cat > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/3ed8045c-52b8-4647-9fe6-c0326aaf923do%40googlegroups.com.
