Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #15559 - distinct queries introduced by [15607] cause e…

…rrors with some custom model fields

This patch just reverts [15607] until a more satisfying solution can be
found.

Refs #11707

Backport of [15791] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15792 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2bb360c91c42ae7a23ad7330fc13d98a6d9efa5f 1 parent ec7dd58
Luke Plant authored March 10, 2011
2  django/db/models/fields/related.py
@@ -904,7 +904,7 @@ def formfield(self, **kwargs):
5  tests/regressiontests/model_fields/models.py
@@ -29,11 +29,6 @@ class Bar(models.Model):
29 29
     b = models.CharField(max_length=10)
30 30
     a = models.ForeignKey(Foo, default=get_foo)
31 31
 
32  
-class Baz(models.Model):
33  
-    a = models.CharField(max_length=5)
34  
-    #Only Foos related to Bars starting with 'a'
35  
-    foo = models.ForeignKey(Foo, limit_choices_to=models.Q(bar__b__startswith='a'))
36  
-
37 32
 class Whiz(models.Model):
38 33
     CHOICES = (
39 34
         ('Group 1', (
19  tests/regressiontests/model_fields/tests.py
... ...
@@ -1,14 +1,13 @@
1 1
 import datetime
2 2
 import unittest
3 3
 from decimal import Decimal
4  
-import re
5 4
 
6 5
 import django.test
7 6
 from django import forms
8 7
 from django.db import models
9 8
 from django.core.exceptions import ValidationError
10 9
 
11  
-from models import Foo, Bar, Baz, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel
  10
+from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel
12 11
 
13 12
 # If PIL available, do these tests.
14 13
 if Image:
@@ -95,10 +94,6 @@ def test_lookup_really_big_value(self):
95 94
         # This should not crash. That counts as a win for our purposes.
96 95
         Foo.objects.filter(d__gte=100000000000)
97 96
 
98  
-class BazForm(forms.ModelForm):
99  
-    class Meta:
100  
-        model = Baz
101  
-
102 97
 class ForeignKeyTests(django.test.TestCase):
103 98
     def test_callable_default(self):
104 99
         """Test the use of a lazy callable for ForeignKey.default"""
@@ -106,18 +101,6 @@ def test_callable_default(self):
106 101
         b = Bar.objects.create(b="bcd")
107 102
         self.assertEqual(b.a, a)
108 103
 
109  
-    def test_distinct_choice_limit(self):
110  
-        """Doesn't make sense to offer the same ForeignKey multiple times in a form"""
111  
-        a = Foo.objects.create(a='a', d=Decimal("-1"))
112  
-        b = Foo.objects.create(a='b', d=Decimal("1"))
113  
-        bar_a = Bar.objects.create(b='ah', a=a)
114  
-        bar_b = Bar.objects.create(b='aha', a=a)
115  
-        bar_b = Bar.objects.create(b='bla', a=b)
116  
-        form = BazForm()
117  
-        fk_field = str(form['foo'])
118  
-        self.assertEqual(len(re.findall(r'value="%d"' % b.pk, fk_field)), 0)
119  
-        self.assertEqual(len(re.findall(r'value="%d"' % a.pk, fk_field)), 1)
120  
-
121 104
 class DateTimeFieldTests(unittest.TestCase):
122 105
     def test_datetimefield_to_python_usecs(self):
123 106
         """DateTimeField.to_python should support usecs"""

0 notes on commit 2bb360c

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