我正在创建一个项目来进行集体翻译,所以我得到了带有图像的原始文本。基本思想是将文本分成块,块可以是不同的类型:文本和图像(可以上传图像,可以编辑 alt 和描述......)
有概念验证
class Source(models.Model):
title = models.CharField(max_length=255, unique=True)
class SourceChunk(models.Model):
source = models.ForeignKey(Source)
class SourceTextChunk(models.Model):
chunk = models.ForeignKey(SourceChunk)
text = models.TextField()
class SourceImageChunk(models.Model):
chunk = models.ForeignKey(SourceChunk)
image = models.FileField()
alt = models.TextField()
title = models.TextField()
transcription = models.TextField()
class SourceAdmin(admin.ModelAdmin):
pass
我想使用 SourceAdmin(在管理页面中)创建表单,它将以这种方式显示:
... some other fields ...
text form
text form
text form
text form
image form
text form
text form
text form