yes, but the problem is that we manually give them a pk.
Maye it's the best to reduce the question to the following: Which (undocumented) field is better for this case? * instance._state.db (checking if this is None) * instance_state.adding (checking for True) bg, Johannes On 21.01.2014 10:07, Avraham Serour wrote:
wouldn't checking for the presence of an id enough? as far as I know instantiated objects don't have id's On Tue, Jan 21, 2014 at 10:16 AM, Erik Cederstrand <[email protected] <mailto:[email protected]>> wrote: Den 21/01/2014 kl. 08.58 skrev Johannes Schneider <[email protected] <mailto:[email protected]>>: > maybe I I formulated it not precise enough. > I need to check if some instance of a model comes from some database query (e.g. via get(..)) or is instanciated 'by hand'. and not jet written to the database. > In this case I don't need to know, if there is an related object (e.g. with the same pk or same values for its attributes) in the database. Okay. Sounds like your best bet is to either roll your own, or use the undocumented API as suggested by Tom Evans. Either way, make sure to write tests so this doesn’t break when you upgrade Django. Erik -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:django-users%[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/78B3DC94-CBFC-4F38-A35C-73F54CAB572A%40cederstrand.dk. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFWa6t%2Brm9REWaWUTqZHd4Wv3Pw212RLGSh89%2BWJwC7NFNM%3DqQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
-- Johannes Schneider Webentwicklung [email protected] Tel.: +49.228.42150.xxx Galileo Press GmbH Rheinwerkallee 4 - 53227 Bonn - Germany Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax) http://www.galileo-press.de/ Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker HRB 8363 Amtsgericht Bonn -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/52DE442B.1010300%40galileo-press.de. For more options, visit https://groups.google.com/groups/opt_out.

