In one of my apps, I need to check and see if a row already exists  
based on a unique field. Currently, I'm doing something like the  
following:


for photo in photos:
     try:
         row = Photo.objects.get(flickr_id=photo("id"))
         # Raise exception if photo doesn't exist in our DB yet
     except ObjectDoesNotExist:
         [[[Make the object, etc]]]


However, raising an exception on "success" irks the part of me that  
studied computer science for 3 years, so I'm wondering if anyone  
knows of any other ways I might be able to achieve the above in a  
better way.

Thanks,
Tyson

-- 
Tyson Tate
- CalPoly Graphic Design Student
- Work: Graphic Designer (CalPoly Library)
- Play: Mustang Band, CalPoly Triathlon Team, Kappa Kappa Psi (Iota Pi)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to