﻿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
8681	Uncaught exception in django/db/models/base.py: UnboundLocalError	HM <hanne.moa@…>	nobody	"In source:django/trunk/django/db/models/base.py as of [8696], lines 197-203:

{{{
#!python
        for field in fields_iter:
            rel_obj = None
            if kwargs:
                if isinstance(field.rel, ManyToOneRel):
                    try:
                        # Assume object instance was passed in.
                        rel_obj = kwargs.pop(field.name)
}}}

If kwargs[field.name] is None, rel_obj is set to None, val is not set at all, and we get an UnboundLocalError at line 226. Context: the model in question had a OneToOneField whose primary_key was not yet set/was set to None and a save() was attempted.

See stacktrace at dpaste: http://dpaste.com/74655/

Either we need to have a better error-message here, for instance mentioning what field is the problem and how it can be fixed, or the code needs to do something sensible."		closed	Core (Other)	dev		invalid	models, onetoonefield		Unreviewed	0	0	0	0	0	0
