Make OneToOneSource.target nullable

This commit is contained in:
Yuri Prezument 2013-08-12 21:01:37 +03:00
parent 0a92e1ad8c
commit abe655e061

View File

@ -10,7 +10,8 @@ class OneToOneTarget(models.Model):
class OneToOneSource(models.Model): class OneToOneSource(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
target = models.OneToOneField(OneToOneTarget, related_name='source') target = models.OneToOneField(OneToOneTarget, related_name='source',
null=True, blank=True)
class OneToManyTarget(models.Model): class OneToManyTarget(models.Model):
@ -21,7 +22,7 @@ class OneToManySource(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
target = models.ForeignKey(OneToManyTarget, related_name='sources') target = models.ForeignKey(OneToManyTarget, related_name='sources')
class ReverseNestedOneToOneTests(TestCase): class ReverseNestedOneToOneTests(TestCase):
def setUp(self): def setUp(self):
class OneToOneSourceSerializer(serializers.ModelSerializer): class OneToOneSourceSerializer(serializers.ModelSerializer):