#29148: Explain how to use QuerySet.get_or_create() with Q objects
-------------------------------+---------------------------------------
Reporter: Mike Lissner | Owner: Dhruv Singh
Type: New feature | Status: assigned
Component: Documentation | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+---------------------------------------
Comment (by Herbert Fortes):
Hi Dhruv Singh,
Do you still intent to make a PR to close the ticket?
I have something like this:
Differently from :meth:`~django.db.models.query.QuerySet.get` method, the
:meth:`~django.db.models.query.QuerySet.get_or_create` method must be used
with the :meth:`~django.db.models.query.QuerySet.filter` lookup function.
For example::
Poll.objects.filter(
Q(first_name='Bryan') | Q(first_name='Bruce')
).get_or_create({'last_name': 'Harrison'})
--
Ticket URL: <https://code.djangoproject.com/ticket/29148#comment:5>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.ccb5822bb473bd635b88e8350e12c2e2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.