Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed some unnecessary __exact operators in filters.

  • Loading branch information...
commit b87c59b04bc549a5ba42023d04e4be7a4737f7d9 1 parent 298a2b5
Tim Graham authored January 17, 2014
2  django/contrib/admin/options.py
@@ -1620,7 +1620,7 @@ def history_view(self, request, object_id, extra_context=None):
1620 1620
         app_label = opts.app_label
1621 1621
         action_list = LogEntry.objects.filter(
1622 1622
             object_id=unquote(object_id),
1623  
-            content_type__id__exact=ContentType.objects.get_for_model(model).id
  1623
+            content_type=ContentType.objects.get_for_model(model)
1624 1624
         ).select_related().order_by('action_time')
1625 1625
 
1626 1626
         context = dict(self.admin_site.each_context(),
2  django/contrib/admin/templatetags/log.py
@@ -18,7 +18,7 @@ def render(self, context):
18 18
             user_id = self.user
19 19
             if not user_id.isdigit():
20 20
                 user_id = context[self.user].pk
21  
-            context[self.varname] = LogEntry.objects.filter(user__pk__exact=user_id).select_related('content_type', 'user')[:int(self.limit)]
  21
+            context[self.varname] = LogEntry.objects.filter(user__pk=user_id).select_related('content_type', 'user')[:int(self.limit)]
22 22
         return ''
23 23
 
24 24
 
2  django/contrib/contenttypes/generic.py
@@ -324,7 +324,7 @@ def __init__(self, model=None, instance=None, symmetrical=None,
324 324
             self.pk_val = self.instance._get_pk_val()
325 325
             self.core_filters = {
326 326
                 '%s__pk' % content_type_field_name: content_type.id,
327  
-                '%s__exact' % object_id_field_name: instance._get_pk_val(),
  327
+                '%s' % object_id_field_name: instance._get_pk_val(),
328 328
             }
329 329
 
330 330
         def __call__(self, **kwargs):
4  django/contrib/flatpages/views.py
@@ -35,12 +35,12 @@ def flatpage(request, url):
35 35
     site_id = get_current_site(request).id
36 36
     try:
37 37
         f = get_object_or_404(FlatPage,
38  
-            url__exact=url, sites__id__exact=site_id)
  38
+            url=url, sites=site_id)
39 39
     except Http404:
40 40
         if not url.endswith('/') and settings.APPEND_SLASH:
41 41
             url += '/'
42 42
             f = get_object_or_404(FlatPage,
43  
-                url__exact=url, sites__id__exact=site_id)
  43
+                url=url, sites=site_id)
44 44
             return HttpResponsePermanentRedirect('%s/' % request.path)
45 45
         else:
46 46
             raise
2  django/contrib/sites/managers.py
@@ -39,4 +39,4 @@ def _validate_field_name(self):
39 39
     def get_queryset(self):
40 40
         if not self.__is_validated:
41 41
             self._validate_field_name()
42  
-        return super(CurrentSiteManager, self).get_queryset().filter(**{self.__field_name + '__id__exact': settings.SITE_ID})
  42
+        return super(CurrentSiteManager, self).get_queryset().filter(**{self.__field_name + '__id': settings.SITE_ID})
2  docs/ref/contrib/sites.txt
@@ -84,7 +84,7 @@ This accomplishes several things quite nicely:
84 84
 
85 85
       def article_detail(request, article_id):
86 86
           try:
87  
-              a = Article.objects.get(id=article_id, sites__id__exact=get_current_site(request).id)
  87
+              a = Article.objects.get(id=article_id, sites__id=get_current_site(request).id)
88 88
           except Article.DoesNotExist:
89 89
               raise Http404
90 90
           # ...
2  docs/topics/auth/default.txt
@@ -101,7 +101,7 @@ You can also change a password programmatically, using
101 101
 .. code-block:: python
102 102
 
103 103
     >>> from django.contrib.auth.models import User
104  
-    >>> u = User.objects.get(username__exact='john')
  104
+    >>> u = User.objects.get(username='john')
105 105
     >>> u.set_password('new password')
106 106
     >>> u.save()
107 107
 
6  docs/topics/db/examples/many_to_many.txt
@@ -111,7 +111,7 @@ Create and add a ``Publication`` to an ``Article`` in one step using
111 111
 Many-to-many relationships can be queried using :ref:`lookups across
112 112
 relationships <lookups-that-span-relationships>`::
113 113
 
114  
-    >>> Article.objects.filter(publications__id__exact=1)
  114
+    >>> Article.objects.filter(publications__id=1)
115 115
     [<Article: Django lets you build Web apps easily>, <Article: NASA uses Python>]
116 116
     >>> Article.objects.filter(publications__pk=1)
117 117
     [<Article: Django lets you build Web apps easily>, <Article: NASA uses Python>]
@@ -143,7 +143,7 @@ The :meth:`~django.db.models.query.QuerySet.count` function respects
143 143
 Reverse m2m queries are supported (i.e., starting at the table that doesn't have
144 144
 a :class:`~django.db.models.ManyToManyField`)::
145 145
 
146  
-    >>> Publication.objects.filter(id__exact=1)
  146
+    >>> Publication.objects.filter(id=1)
147 147
     [<Publication: The Python Journal>]
148 148
     >>> Publication.objects.filter(pk=1)
149 149
     [<Publication: The Python Journal>]
@@ -151,7 +151,7 @@ a :class:`~django.db.models.ManyToManyField`)::
151 151
     >>> Publication.objects.filter(article__headline__startswith="NASA")
152 152
     [<Publication: Highlights for Children>, <Publication: Science News>, <Publication: Science Weekly>, <Publication: The Python Journal>]
153 153
 
154  
-    >>> Publication.objects.filter(article__id__exact=1)
  154
+    >>> Publication.objects.filter(article__id=1)
155 155
     [<Publication: The Python Journal>]
156 156
     >>> Publication.objects.filter(article__pk=1)
157 157
     [<Publication: The Python Journal>]
6  docs/topics/db/examples/many_to_one.txt
@@ -123,7 +123,7 @@ This works as many levels deep as you want. There's no limit. For example::
123 123
     [<Article: This is a test>]
124 124
 
125 125
     # Find all Articles for any Reporter whose first name is "John".
126  
-    >>> Article.objects.filter(reporter__first_name__exact='John')
  126
+    >>> Article.objects.filter(reporter__first_name='John')
127 127
     [<Article: John's second story>, <Article: This is a test>]
128 128
 
129 129
 Exact match is implied here::
@@ -134,7 +134,7 @@ Exact match is implied here::
134 134
 Query twice over the related field. This translates to an AND condition in the
135 135
 WHERE clause::
136 136
 
137  
-    >>> Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith')
  137
+    >>> Article.objects.filter(reporter__first_name='John', reporter__last_name='Smith')
138 138
     [<Article: John's second story>, <Article: This is a test>]
139 139
 
140 140
 For the related lookup you can supply a primary key value or pass the related
@@ -184,7 +184,7 @@ Queries can go round in circles::
184 184
     [<Reporter: John Smith>, <Reporter: John Smith>, <Reporter: John Smith>, <Reporter: John Smith>]
185 185
     >>> Reporter.objects.filter(article__reporter__first_name__startswith='John').distinct()
186 186
     [<Reporter: John Smith>]
187  
-    >>> Reporter.objects.filter(article__reporter__exact=r).distinct()
  187
+    >>> Reporter.objects.filter(article__reporter=r).distinct()
188 188
     [<Reporter: John Smith>]
189 189
 
190 190
 If you delete a reporter, his articles will be deleted (assuming that the
2  docs/topics/db/examples/one_to_one.txt
@@ -113,7 +113,7 @@ This of course works in reverse::
113 113
 
114 114
     >>> Place.objects.get(pk=1)
115 115
     <Place: Demon Dogs the place>
116  
-    >>> Place.objects.get(restaurant__place__exact=p1)
  116
+    >>> Place.objects.get(restaurant__place=p1)
117 117
     <Place: Demon Dogs the place>
118 118
     >>> Place.objects.get(restaurant=r)
119 119
     <Place: Demon Dogs the place>
4  docs/topics/db/queries.txt
@@ -411,7 +411,7 @@ can specify the field name suffixed with ``_id``. In this case, the value
411 411
 parameter is expected to contain the raw value of the foreign model's primary
412 412
 key. For example:
413 413
 
414  
-    >>> Entry.objects.filter(blog_id__exact=4)
  414
+    >>> Entry.objects.filter(blog_id=4)
415 415
 
416 416
 If you pass an invalid keyword argument, a lookup function will raise
417 417
 ``TypeError``.
@@ -489,7 +489,7 @@ want.
489 489
 This example retrieves all ``Entry`` objects with a ``Blog`` whose ``name``
490 490
 is ``'Beatles Blog'``::
491 491
 
492  
-    >>> Entry.objects.filter(blog__name__exact='Beatles Blog')
  492
+    >>> Entry.objects.filter(blog__name='Beatles Blog')
493 493
 
494 494
 This spanning can be as deep as you'd like.
495 495
 

0 notes on commit b87c59b

Please sign in to comment.
Something went wrong with that request. Please try again.