Changes between Initial Version and Version 1 of Ticket #34884, comment 1


Ignore:
Timestamp:
Sep 29, 2023, 7:18:48 PM (14 months ago)
Author:
Laurent Lyaudet

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34884, comment 1

    initial v1  
    1212def patched_get_or_create(self, defaults=None, **kwargs):
    1313     result, created = original_get_or_create(self, defaults=defaults, **kwargs)
    14      if defaults is not None:
     14     if defaults is not None and created:
    1515         for key, value in defaults.items():
    1616             if isinstance(result._meta.get_field(key), ForeignKey):
     
    3737In [17]: def patched_get_or_create(self, defaults=None, **kwargs):
    3838    ...:      result, created = original_get_or_create(self, defaults=defaults, **kwargs)
    39     ...:      if defaults is not None:
     39    ...:      if defaults is not None and created:
    4040    ...:          for key, value in defaults.items():
    4141    ...:              if isinstance(result._meta.get_field(key), ForeignKey):
Back to Top