Refs #25415 -- Fixed invalid models in the test suite.

This commit is contained in:
Adam Chainz 2016-03-18 14:24:29 +00:00 committed by Tim Graham
parent bae64dd0f1
commit 652bcc6f5f
10 changed files with 16 additions and 17 deletions

View File

@ -80,8 +80,8 @@ class Time(models.Model):
@python_2_unicode_compatible
class SimulationRun(models.Model):
start = models.ForeignKey(Time, models.CASCADE, null=True)
end = models.ForeignKey(Time, models.CASCADE, null=True)
start = models.ForeignKey(Time, models.CASCADE, null=True, related_name='+')
end = models.ForeignKey(Time, models.CASCADE, null=True, related_name='+')
midpoint = models.TimeField()
def __str__(self):

View File

@ -80,7 +80,7 @@ class BrokenContainsRelation(StartsWithRelation):
@python_2_unicode_compatible
class SlugPage(models.Model):
slug = models.CharField(max_length=20)
slug = models.CharField(max_length=20, unique=True)
descendants = StartsWithRelation(
'self',
from_fields=['slug'],

View File

@ -45,7 +45,7 @@ class Article(models.Model):
body = models.TextField(default='')
reporter = models.ForeignKey(Reporter, models.CASCADE)
response_to = models.ForeignKey('self', models.SET_NULL, null=True)
unmanaged_reporters = models.ManyToManyField(Reporter, through='ArticleReporter')
unmanaged_reporters = models.ManyToManyField(Reporter, through='ArticleReporter', related_name='+')
def __str__(self):
return self.headline

View File

@ -51,7 +51,6 @@ class Article(models.Model):
class AbstractArticle(models.Model):
class Meta:
abstract = True
ordering = ('title',)
publications = models.ManyToManyField(Publication, name='publications', related_name='+')

View File

@ -131,7 +131,7 @@ class Author(models.Model):
class Author1(models.Model):
publication = models.OneToOneField(Publication, models.SET_NULL, null=False)
publication = models.OneToOneField(Publication, models.CASCADE, null=False)
full_name = models.CharField(max_length=255)

View File

@ -166,7 +166,7 @@ class MexicanRestaurant(Restaurant):
class ClassyMexicanRestaurant(MexicanRestaurant):
restaurant = models.OneToOneField(MexicanRestaurant, models.CASCADE, parent_link=True, primary_key=True)
the_restaurant = models.OneToOneField(MexicanRestaurant, models.CASCADE, parent_link=True, primary_key=True)
tacos_are_yummy = models.BooleanField(default=False)

View File

@ -1461,7 +1461,7 @@ class ModelFormsetTest(TestCase):
# a formset for a Model that has a custom primary key that still needs to be
# added to the formset automatically
FormSet = modelformset_factory(ClassyMexicanRestaurant, fields=["tacos_are_yummy"])
self.assertEqual(sorted(FormSet().forms[0].fields.keys()), ['restaurant', 'tacos_are_yummy'])
self.assertEqual(sorted(FormSet().forms[0].fields.keys()), ['tacos_are_yummy', 'the_restaurant'])
def test_model_formset_with_initial_model_instance(self):
# has_changed should compare model instance and primary key

View File

@ -134,11 +134,11 @@ class CommonAncestor(models.Model):
class FirstParent(CommonAncestor):
first_ancestor = models.OneToOneField(CommonAncestor, models.SET_NULL, primary_key=True, parent_link=True)
first_ancestor = models.OneToOneField(CommonAncestor, models.CASCADE, primary_key=True, parent_link=True)
class SecondParent(CommonAncestor):
second_ancestor = models.OneToOneField(CommonAncestor, models.SET_NULL, primary_key=True, parent_link=True)
second_ancestor = models.OneToOneField(CommonAncestor, models.CASCADE, primary_key=True, parent_link=True)
class Child(FirstParent, SecondParent):

View File

@ -25,7 +25,7 @@ class Author(models.Model):
@python_2_unicode_compatible
class Article(models.Model):
author = models.ForeignKey(Author, models.SET_NULL, null=True)
second_author = models.ForeignKey(Author, models.SET_NULL, null=True)
second_author = models.ForeignKey(Author, models.SET_NULL, null=True, related_name='+')
headline = models.CharField(max_length=100)
pub_date = models.DateTimeField()

View File

@ -526,8 +526,8 @@ class Job(models.Model):
class JobResponsibilities(models.Model):
job = models.ForeignKey(Job, models.SET_NULL, to_field='name')
responsibility = models.ForeignKey('Responsibility', models.SET_NULL, to_field='description')
job = models.ForeignKey(Job, models.CASCADE, to_field='name')
responsibility = models.ForeignKey('Responsibility', models.CASCADE, to_field='description')
@python_2_unicode_compatible
@ -620,7 +620,7 @@ class Order(models.Model):
@python_2_unicode_compatible
class OrderItem(models.Model):
order = models.ForeignKey(Order, models.SET_NULL, related_name='items')
order = models.ForeignKey(Order, models.CASCADE, related_name='items')
status = models.IntegerField()
class Meta:
@ -637,8 +637,8 @@ class BaseUser(models.Model):
@python_2_unicode_compatible
class Task(models.Model):
title = models.CharField(max_length=10)
owner = models.ForeignKey(BaseUser, models.SET_NULL, related_name='owner')
creator = models.ForeignKey(BaseUser, models.SET_NULL, related_name='creator')
owner = models.ForeignKey(BaseUser, models.CASCADE, related_name='owner')
creator = models.ForeignKey(BaseUser, models.CASCADE, related_name='creator')
def __str__(self):
return self.title
@ -654,7 +654,7 @@ class Staff(models.Model):
@python_2_unicode_compatible
class StaffUser(BaseUser):
staff = models.OneToOneField(Staff, models.SET_NULL, related_name='user')
staff = models.OneToOneField(Staff, models.CASCADE, related_name='user')
def __str__(self):
return self.staff