﻿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
18532	Mark when instance is loaded from database for pre-/post-init receivers.	Vlastimil Zíma	nobody	"There is no way to find out if instance exists in database until initializing is complete. There is attribute Model._state.adding, but it is set after instance is initialized.

{{{
#!python
from django.db import models
from django.db.models import signals

class Parent(models.Model):
    pass

def callback(instance, **kwargs)
    print instance._state.adding

signals.post_init.connect(callback, sender=Parent)

p = Parent.objects.get(pk=1)
>>> True
p._state.adding
>>> False
}}}

Such flag can come handy to avoid subsequent SELECT queries to find out whether instance already exists in database."	New feature	closed	Database layer (models, ORM)	1.4	Normal	wontfix			Unreviewed	0	0	0	0	0	0
