13 | | result, created = original_get_or_create(self, defaults=defaults, **kwargs) |
14 | | if not created: |
15 | | for key, value in kwargs.items(): |
16 | | if isinstance(result._meta.get_field(key), ForeignKey): |
17 | | # isinstance handles OneToOneField also. |
18 | | setattr(result, key, value) |
19 | | return result, created |
| 14 | result, created = original_get_or_create(self, defaults=defaults, **kwargs) |
| 15 | if not created: |
| 16 | for key, value in kwargs.items(): |
| 17 | try: |
| 18 | if isinstance(result._meta.get_field(key), ForeignKey): |
| 19 | # isinstance handles OneToOneField also. |
| 20 | setattr(result, key, value) |
| 21 | except FieldDoesNotExist: |
| 22 | pass |
| 23 | return result, created |