0
mikser:; Django Sahte nesnelerle kendini başvuran FKs test django tipik çalışma zamanı hatası alıyorum
In [12]: from mixer.backend.django import mixer
In [13]: x = mixer.blend(ItemGroup)
/home/cchilders/.virtualenvs/clientsite/lib/python3.4/site-packages/django/db/models/fields/related.py in __set__(self, instance, value)
587 raise ValueError(
588 'Cannot assign None: "%s.%s" does not allow null values.' %
--> 589 (instance._meta.object_name, self.field.name)
590 )
591 elif value is not None and not isinstance(value, self.field.rel.to):
ValueError: Mixer (<class 'clientsite.gacl.models.AroGroup'>): Cannot assign None: "AroGroup.parent" does not allow null values.
modeli:
class ItemGroup(models.Model):
parent = models.ForeignKey('self', db_column='parent_id')
name = models.CharField(max_length=255)
value = models.CharField(max_length=255, unique=True)
class Meta:
db_table = u'item_groups'
def __str__(self):
return self.value
def __repr__(self):
return '<{} {}: {}>'.format(self.__class__.__name__, self.pk, self.value)
docs FK olarak kendinizi başvuran üzerinde seyrek. Django mikser ile kendinden birisini gerektiren bir örneği nasıl taklit edebilirsin? Teşekkür ederiz