﻿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
13679	ModelForms (and hence the admin) no longer honor the default value for a ForeignKey	3point2	nobody	"In Django 1.1, it was possible to use a callable to set the default value on a !ForeignKey field. This functionality was broken in r12721 and doesn't currently work in Django 1.2.

Example:
{{{
def get_default():
    return SomeModel.objects.get(id=5)

class Test(models.Model):
    foo = models.ForeignKey(SomeModel, default=get_default)
}}}

This model should display in the admin with the default !SomeModel already selected in the drop-down box. The !ModelForm code that does this seems to have been confused by the changes made in r12721.

The code in the Field class in django/db/models/fields/!__init!__.py could also do with a cleanup: formfield() first checks has_default() before calling get_default(), which also checks has_default(). The patch in r12721 adds to this duplication of logic by checking if self.default is callable, which is also done by get_default()."		closed	Forms	1.2		fixed			Accepted	0	0	0	0	0	0
