#27613: BaseInlineFormSet is validating form for extra forms
-------------------------------------------+-------------------------
Reporter: Sonu kumar | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Release blocker | Keywords: FormSet
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------------+-------------------------
{{{
class ExplanationFormSet(BaseInlineFormSet):
def clean(self):
super(ExplanationFormSet, self).clean()
for form in self.forms:
if not hasattr(form, 'cleaned_data'):
continue
data = form.cleaned_data
if data.get('description') is None or data.get('description')
== "":
continue
if data.get('user') == None:
raise ValidationError("Explanation Author is required")
@python_2_unicode_compatible
class Explanation(models.Model):
user = models.ForeignKey(User)
question = models.ForeignKey(Question)
description = models.TextField()
creation = models.DateTimeField(auto_now_add=True)
last_change = models.DateTimeField(auto_now_add=True)
past_explanation = models.ForeignKey('self', on_delete=models.CASCADE,
db_constraint=False, blank=True,
default=-1, null=True)
valid = models.BooleanField(default=False)
def __str__(self):
return str(self.description[:40])
class ExplanationInline(TabularInline):
model = Explanation
formset = ExplanationFormSet
extra = 1
@register(Question)
class QuestionAdmin(ModelAdmin):
inlines = [
ItemInline,
ExplanationInline,
]
list_filter = ['multiple_correct', 'timestamp','field__field_name',
'field__subfield_name' ]
exclude = ('timestamp',)
date_hierarchy = 'timestamp'
search_fields = ['header']
}}}
Problem:
When Question is edited in admin panel then it always throws an error for
one additional form added at last. Form throws the error for all fields
whose value(s) are required. This is especially seen for
ExplanationFormSet.
--
Ticket URL: <https://code.djangoproject.com/ticket/27613>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.f95dec40f51c02d660cbbf88557f825b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.