Re: [Django] #5763: Queryset doesn't have a "not equal" filter operator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #5763: Queryset doesn't have a "not equal" filter operator

Django
#5763: Queryset doesn't have a "not equal" filter operator
-------------------------------------+-------------------------------------
     Reporter:  jdetaeye             |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  qs-rf                |             Triage Stage:  Design
                                     |  decision needed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by cpbotha):

 Is there a way to work around the absence of the `ne` operator when one
 wants to do a `get_or_create()` or an `update_or_create()` where one wants
 to select records with a non-blank text field value?

 In other words, how would I do for example
 `Blog.objects.update_or_create(text_contents__ne='',
 other_field_indicating_sort=42, defaults={yet_another_field: True})` ?

--
Ticket URL: <https://code.djangoproject.com/ticket/5763#comment:25>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.a94785679ff30b28862ac53c170813aa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #5763: Queryset doesn't have a "not equal" filter operator

Django
#5763: Queryset doesn't have a "not equal" filter operator
-------------------------------------+-------------------------------------
     Reporter:  jdetaeye             |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  qs-rf                |             Triage Stage:  Design
                                     |  decision needed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 You should be able to use `exclude` for that.


 {{{#!python
 Blog.objects.exclude(
     text_contents='',
 ).update_or_create(
     other_field_indicating_sort=42,
     defaults={yet_another_field: True},
 )
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/5763#comment:26>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.f34f063a72d1a2dd826a82ccd4bcb78b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.