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 <erik+lists@cederstrand.dk> wrote:
Den 21/01/2014 kl. 08.58 skrev Johannes Schneider <johannes.schneider@galileo-press.de>:
Okay. Sounds like your best bet is to either roll your own, or use the undocumented API as suggested by Tom Evans.
> 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.
Either way, make sure to write tests so this doesn't break when you upgrade Django.
Erik
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/78B3DC94-CBFC-4F38-A35C-73F54CAB572A%40cederstrand.dk.
--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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.
No comments:
Post a Comment