diff options
author | Alexander Sosnovskiy <alecs.box@gmail.com> | 2015-07-02 11:43:15 +0300 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-12-25 20:01:31 -0500 |
commit | 2a7ce34600d0f879e93c9a5e02215948ed3bb6ac (patch) | |
tree | d1a4770772b452513e1d64c090dc15ae287afe70 /tests/many_to_one | |
parent | a1d0c60fa05cbad2e5a25ec37e0afaf1b84c9302 (diff) | |
download | django-2a7ce34600d0f879e93c9a5e02215948ed3bb6ac.tar.gz |
Fixed #14286 -- Added models.BigAutoField.
Diffstat (limited to 'tests/many_to_one')
-rw-r--r-- | tests/many_to_one/models.py | 18 | ||||
-rw-r--r-- | tests/many_to_one/tests.py | 13 |
2 files changed, 29 insertions, 2 deletions
diff --git a/tests/many_to_one/models.py b/tests/many_to_one/models.py index 57fc7a617b..05491e99f1 100644 --- a/tests/many_to_one/models.py +++ b/tests/many_to_one/models.py @@ -32,6 +32,24 @@ class Article(models.Model): ordering = ('headline',) +@python_2_unicode_compatible +class City(models.Model): + id = models.BigAutoField(primary_key=True) + name = models.CharField(max_length=50) + + def __str__(self): + return self.name + + +@python_2_unicode_compatible +class District(models.Model): + city = models.ForeignKey(City, models.CASCADE) + name = models.CharField(max_length=50) + + def __str__(self): + return self.name + + # If ticket #1578 ever slips back in, these models will not be able to be # created (the field names being lower-cased versions of their opposite # classes is important here). diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py index 69bba0993d..79caec7177 100644 --- a/tests/many_to_one/tests.py +++ b/tests/many_to_one/tests.py @@ -9,8 +9,8 @@ from django.utils.deprecation import RemovedInDjango20Warning from django.utils.translation import ugettext_lazy from .models import ( - Article, Category, Child, First, Parent, Record, Relation, Reporter, - School, Student, Third, ToFieldChild, + Article, Category, Child, City, District, First, Parent, Record, Relation, + Reporter, School, Student, Third, ToFieldChild, ) @@ -569,6 +569,15 @@ class ManyToOneTests(TestCase): self.assertIsNot(c.parent, p) self.assertEqual(c.parent, p) + def test_fk_to_bigautofield(self): + ch = City.objects.create(name='Chicago') + District.objects.create(city=ch, name='Far South') + District.objects.create(city=ch, name='North') + + ny = City.objects.create(name='New York', id=2 ** 33) + District.objects.create(city=ny, name='Brooklyn') + District.objects.create(city=ny, name='Manhattan') + def test_multiple_foreignkeys(self): # Test of multiple ForeignKeys to the same model (bug #7125). c1 = Category.objects.create(name='First') |