Reputation: 3
Edit: Seems like I can't add images :(, added links to imgur instead.
I'm trying to implement settings in order to enter social media accounts.
@register_setting
class SocialMediaSettings(BaseGenericSetting):
discord_url = models.URLField(
help_text="Link used."
)
discord_name = models.CharField(
max_length=100,
help_text="Name to be displayed."
)
gitlab_url = models.URLField(
help_text="Link used."
)
gitlab_name = models.CharField(
max_length=100,
help_text="Name to be displayed."
)
panels = [
FieldPanel("discord_url"),
FieldPanel("discord_name"),
FieldPanel("gitlab_url"),
FieldPanel("gitlab_name")
]
Which works totally fine, but as it feels like a super bad idea to do it this way, I wanted to use a streamfield like this:
@register_setting
class SocialMediaSettings(BaseGenericSetting):
body = StreamField([
("social_account", blocks.SocialBlock()),
], null=True, blank=True, use_json_field=True)
panels = [
FieldPanel("body")
]
class SocialBlock(blocks.StructBlock):
name = blocks.CharBlock(
max_length=100,
help_text="Name used for tooltips."
)
url = blocks.URLBlock(
help_text="URL"
)
Image of wagtail admin (image)
This way it shows up partly. In the admin panel I can only enter the name, not the url. And saving doesn't work eighter (saving will reset what I entered in the admin panel).
Adding the SocialBlock to a normal page works as expected: SocialBlock working in another Page (image)
Which is why I ran out of ideas. Are streamfields not supported in snippets / settings? (the above exapmles are done with @register_setting but I tried @register_snippet with the same result.)
Any idea how I could get this up and running?
Wagtail 4.0 Django 4.1
Upvotes: 0
Views: 232
Reputation: 3
Well, wagtail itself just showed me the solution :x
It was a bug in Wagtail 4.0, which is solved in 4.0.1 Release Notes Wagtail 4.0.1
Upvotes: 0