我有一个 Django 模型:
class ObservationMedia(models.Model):
observation = models.ForeignKey(Observation)
audio_file = AudioFileField ( upload_to=audio_dir, blank=True, null=True )
photo_file = models.ImageField( upload_to=img_dir, blank=True, null=True )
def __unicode__(self):
return "obsv-media "+str(self.pk)
其中观察是:
class Observation(GUIDModel):
guid = models.CharField(unique=True, max_length=36, default=uuid.uuid4)
# many more fields here
是否有可能传递给的值ModelForm
不是其主键而是字段?我想到的解决方案是制作主键。有可能避免这种情况吗?ObservationMedia
Observation
guid
guid