I am using a Wagtail streamfield to allow users to upload and link to documents in the editor interface. Originally, I tried to use a foreign key as referenced in the documentation and as all other examples I have seen. I kept getting an error when running migrations that wagtail document has not property "set name". So I decided to not use a foreign key because these documents do not necessarily need to be related on a one-to-many relationship for our purposes. So in my model, I do not use a foreign key for all the fields using DocumentChooserBlocks and everything seems to work fine. Am I misunderstanding "foreign key" and making a mistake(or practicing bad DB design). Here is my working model for this:
class AgendaPage(Page):
author= models.CharField(max_length=255)
date = models.DateField('Post date')
mtg_date = models.DateField(default=datetime.date.today)
mtg_time = models.CharField(max_length=255, default ='10:00 AM')
full_video_url-models.CharField(required =False)
###full_audio = DocumentChooserBlock(required=False)
###mtg_transcript = DocumentChooserBlock(required=False)
])
agenda = StreamField([
('agenda_item', blocks.StreamBlock([
('item_title', blocks.TextBlock()),
('item_text', blocks.TextBlock()),
('mtg_doc', blocks.StructBlock([
('mtg_doc_upload', DocumentChooserBlock(required=True)),
('submitted_late', blocks.BooleanBlock(required=False, help_text='Submitted Late')),
('heldover', blocks.BooleanBlock(required=False, help_text='Held Over')),
('heldover_from', blocks.DateBlock(required=False, help_text="Held Over From")),
])),
('item_audio', DocumentChooserBlock(required=False)),
]))
])
content_panels = Page.content_panels + [
FieldPanel('author'),
FieldPanel('date'),
FieldPanel('mtg_date'),
FieldPanel('mtg_time'),
StreamFieldPanel('agenda'),
]
Also, in the two commented-out lines in the model, I am trying to have a DocumentChooserBlock that is not inside a streamfield(without foreign key) I know this syntax is likely wrong, as all examples I see, define a forein key in the model definition, and then reference a DocumentChooser Panel in the panels definition. Is it is possible(or advisable) to do it without foreign key?