Tuesday, January 21, 2014

Re: Fast and Easy way to check if an instance of an Model exists in the Database

Den 21/01/2014 kl. 08.58 skrev Johannes Schneider <johannes.schneider@galileo-press.de>:

> 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 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/78B3DC94-CBFC-4F38-A35C-73F54CAB572A%40cederstrand.dk.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate