﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13763	Setting prefix on a ModelForm causes is_valid() to return False	Mark Tranchant	nobody	"Setting the prefix attribute on a ModelForm causes is_valid() to always return False. I can't find anything in the docs that refers to this behaviour. I am bundling multiple ModelForms into a single HTML form, so I'm using the prefix. On submission, I bind each of the ModelForms to their bit of the POST data to process them. If I set the prefix (in case validation fails and I need to re-display) *before* the call to is_valid(), that call always fails.

Here's a quick test case using lightly-simplified versions of my real classes:

{{{
class RptTField(models.Model):
        report = models.ForeignKey(Rpt)
        config = models.ForeignKey(RptCfgTField)
        text = models.TextField()

class RptTForm(forms.ModelForm):
        class Meta:
                model = RptTField
                exclude = ('report','config')

>>> from myproj.models import *
>>> a = RptTForm({'text':'hello world'})
>>> a.prefix
>>> a.is_valid()
True
>>> b = RptTForm({'text':'hello world'},prefix='abc')
>>> b.prefix
'abc'
>>> b.is_valid()
False
}}}

This is using the latest SVN release, 13353."		closed	Forms	dev		invalid	modelform prefix validation is_valid		Unreviewed	0	0	0	0	0	0
