On Sun, 2008-04-06 at 12:13 +0400, Ivan Sagalaev wrote:
> Malcolm Tredinnick wrote:
> > If you only want a unique object, make sure that
> > the arguments you provide as the defaults argument specify it must be
> > unique at the database level.
> 
> BTW, may be get_or_create should be rewritten as:
> 
>      get()
>      try:
>          create()
>      except BackendSpecificUniqueConstraitFailure:
>          get()

That's more or less how it is written, since r7289 (March 18). The only
small problem is the create step, which is a call to the model's save()
method. If you don't supply default data that forces the instance to be
unique, it could result in multiple occurrences in the database. That's
why it really wants to be model.save(create_only=True), or however we
end up spelling that at that point.

Regards,
Malcolm

-- 
Save the whales. Collect the whole set. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to