I've got the following models defined: class FeatureType(models.Model): type = models.CharField(max_length=20)
def __unicode__(self): return self.type class Feature(models.Model): value = models.CharField(max_length=200) type = models.ForeignKey(FeatureType) def __unicode__(self): return u'type=' + repr(self.type.type) + u', value=' + repr (self.value) class Meta: unique_together = ( ("value", "type"), ) This is what I tried for creating a new Feature: ft = Feature(type=FeatureType(type='Color'), value='Red') ft.type.save() ft.save() I get an IntegrityError at ft.save() saying that the type_id must not be NULL. However, this works: ft = Feature(type=FeatureType(type='Color'), value='Red') ft.type.save() ft.type = ft.type ft.save() Now, if I add in 'null=True' to the definition of 'type' in the Feature model, then the first 3-line code set works, and correctly gets the type_id defined. Am I running into a bug, or am I misunderstanding something? - Johnson --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---