﻿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
7335	ModelForm doesn't know how to handle One-to-One field	Philipp Wollermann	nobody	"Lets say I create a model using multi-table inheritance like this:

{{{
class WebApp(models.Model):
	name = models.CharField(max_length=128, unique=True)
	owner = models.ForeignKey(User)
	active = models.BooleanField(default=True)

	preconfig = models.TextField(blank=True)
	autoconfig = models.TextField(blank=True, editable=False)
	postconfig = models.TextField(blank=True)

	class Meta:
		ordering = [""owner"", ""name""]

class DjangoWebApp(WebApp):
	appname = models.CharField(max_length=32)
}}}

Now I create a ModelForm for DjangoWebApp:

{{{
class DjangoWebAppForm(ModelForm):
	class Meta:
		model = DjangoWebApp
}}}

When I render this form, it has all fields from WebApp and also the ""appname"" field from DjangoWebApp - so inheritance seems to work fine. However, it also has a ""webapp_ptr"" field, which is the One-to-One field link from DjangoWebApp to its parent. Of course it doesn't make any sense to set it by hand, as it gets automatically handled by Django. :) Now, if I exclude that field:

{{{
class DjangoWebAppForm(ModelForm):
	class Meta:
		model = DjangoWebApp
		exclude = (""webapp_ptr"",)
}}}

The form renders correctly and I can save it without problems. Everything works just fine :) I can exclude these pointers manually in my app, but I feel it shouldn't be necessary.

What's worse is, that newforms-admin also doesn't know how to handle this, so one can't edit multi-table inherited models using that.

Best regards,

Philipp
"		closed	Forms	dev		fixed		someone@…	Design decision needed	0	0	0	0	0	0
