﻿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
13299	Handicapped objects passed to models signals during loaddata	Patryk Zawadzki	nobody	"The documentation:

http://docs.djangoproject.com/en/1.1/ref/signals/#django.db.models.signals.post_save

...states that actual model instances are to be expected in `post_save` and `pre_save` signals.

This is not the case during loaddata. Models that use natural python inheritance (not proxy or abstract) are passed as handicapped instances that only have their own fields filled. This breaks signals that try to access any of the fields of the parent model. This happens because `loaddata` passes `raw=True` to the `save` method.

Consider the following:

{{{
class Foo(models.Model):
    foo_field = models.IntegerField(default=0)

class Bar(Foo):
    bar_field = models.IntegerField(default=0)
}}}

During loaddata the instance is passed as follows:

{{{
instance.id = None
instance.foo_field = 0
instance.bar_field = 3
}}}

While...

{{{
instance.foo_ptr_id = 1
instance.foo_ptr.id = 1
instance.foo_ptr.foo_field = 2
}}}

I can think of three solutions:

 1. document it throughly and suggest doing something like:
    {{{
if not instance.id: instance = instance.__class__.objects.get(id=instance.pk)
}}}

 2. make `save_base` reconstruct the object before calling signals

 3. ignore signals at all during raw object saves"	Bug	closed	Documentation	1.2-beta	Normal	duplicate			Accepted	0	0	0	0	0	0
