Ooooh. Thanks, Karen.. This is exactly what I wanted. Although I still wouldn't mind a function for when I'm not planning to immediately create the object. Thanks for the tip!
On Mar 30, 3:27 pm, Karen Tracey <[email protected]> wrote: > I think you missed get_or_create: > > http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-cre... > > Karen Alex, The problem with that is that it's not DRY enough for my taste. Before doing that, I'd create a method (sorta like the only() one) that just does that.. def queryset_getNice(self, **kwargs): try return self.get(kwargs) except Model.DoesNotExist: return None Right? Why write the same boilerplate code all over the place? Phill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

