Changes between Initial Version and Version 1 of Ticket #35694


Ignore:
Timestamp:
Aug 20, 2024, 7:11:42 AM (4 months ago)
Author:
KIC
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35694 – Description

    initial v1  
    11While any orm `filter`, `get`, ... accepts a `pk` or instance `get_or_create` does not. For consistency `get_or_create` should also be able to handle instances and pk's interchangeably.
    22
     3
    34models.py:
    4 ```
     5{{{
    56from django.db import models
    67
     
    1415    bar = models.CharField(max_length=100)
    1516
    16 ```
     17}}}
    1718
    1819tests.py
    19 ```
     20{{{
    2021from testing.utils import TestCase
    2122from zfoo import models
     
    3536        models.B.objects.get_or_create(dict(bar="does not exist"), bar="baz", a=a)
    3637        models.B.objects.get_or_create(dict(bar="does not exist"), bar="baz", a=a.pk)  # FAILS
    37 ```
     38}}}
Back to Top