#36235: RelatedManager.all().get_or_create() does not work -------------------------------------+------------------------------------- Reporter: Nick Pope | Owner: (none) Type: Bug | Status: new Component: Database layer | Version: dev (models, ORM) | Severity: Normal | Resolution: Keywords: get_or_create, | Triage Stage: related, manager | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Comment (by Nick Pope):
The following test can be added to `GetOrCreateTests` in `tests/get_or_create/tests.py` below `test_get_or_create_on_related_manager`: {{{#!python def test_get_or_create_on_related_queryset(self): p = Publisher.objects.create(name="Acme Publishing") # Create a book through the publisher. book, created = p.books.all().get_or_create(name="The Book of Ed & Fred") self.assertTrue(created) # The publisher should have one book. self.assertEqual(p.books.count(), 1) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/36235#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/0107019570560d6d-ec1e06da-b44c-495b-96f1-faa7be6ca3b3-000000%40eu-central-1.amazonses.com.