Ticket #6641: query.diff
File query.diff, 1.0 KB (added by , 17 years ago) |
---|
-
django/db/models/query.py
273 273 try: 274 274 return self.get(**kwargs), False 275 275 except self.model.DoesNotExist: 276 params = dict([(k, v) for k, v in kwargs.items() if '__' not in k]) 277 params.update(defaults) 278 obj = self.model(**params) 279 obj.save() 280 return obj, True 276 try: 277 params = dict([(k, v) for k, v in kwargs.items() if '__' not in k]) 278 params.update(defaults) 279 obj = self.model(**params) 280 obj.save() 281 return obj, True 282 except Exception, e: 283 if str(type(e)).find('IntegrityError') > -1: 284 return self.get(**kwargs), False 285 else: 286 raise e 281 287 282 288 def latest(self, field_name=None): 283 289 """