﻿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
4022	Problem with select fields and foreign keys	hadsie@…	Jacob	"I posted a similar message to this on the django users list a couple days ago but go no response, so it's possible this is actually a bug (not just a user error :)).

The problem is with values not getting saved in select fields. Specifically, select fields that are referencing an external type.

Say I have a model such as:

class MyModel(models.Model):
  field1 = models.ForeignKey(Foo)
  field2 = models.CharField(choices = (('1', 'first choice'), ('2', 'second
choice')))

When I use a manipulator to build the form all goes smoothly. However, if I select a value for field1 on the form, but not field2 I'll get an error since field2 is required. But when this happens field1 gets reset, so the value isn't being saved. If I go the other way, and set field2, but not field1, I'll get an error message again but field2 will have its values preserved.

Looking into the django code a bit I narrowed down the issue to the django.oldforms.FormField.extract_data method. When it runs the line:
  data = data_dict.get(self.get_member_name(), None)

The data for field1 won't be returned. I believe this is because the 'member_name' for field1 is field1_id, but the 'field_name' is field1.

Let me know if there's any other information I can provide.

- Scott
"		closed	Uncategorized	0.96		invalid			Unreviewed	0	0	0	0	0	0
