Media Chooser not Appearing
jpbeltrami opened this issue Β· 12 comments
When Using the BaseMediaChooserPanel as mentioned in #53 the chooser doesn't open when clicking on the "choose a media item" button in the edit page.
Hey @Aesirry, thanks for the report. I imagine you'd have encountered that when trying to upgrade to the latest version, but it might be useful to get this confirmed. Could you provide the following info:
- Python version: Run
python --version
. - Django version: Look in your requirements.txt, or run
pip show django | grep Version
. - Wagtail version: Hover over the Wagtail bird in the admin, or run
pip show wagtail | grep Version:
. wagtailmedia
version: Look in your requirements.txt, or runpip show wagtailmedia | grep Version
.
Additionally, could you provide us with a sample of the code where you use BaseMediaChooserPanel
?
Hi @thibaudcolas,
- Python 3.7.2
- Django 2.2.1
- Wagtail 2.5.1
- WagtailMedia 0.3.0
Here is where I use the Base MediaChooserPanel:
class VideoPage(Page):
author = models.CharField(max_length=255)
date = models.DateField("Post date")
body = models.TextField(blank=False)
media = models.ForeignKey(
get_media_model_string(),
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
content_panels = Page.content_panels + [
FieldPanel('author'),
FieldPanel('date'),
FieldPanel('body'),
BaseMediaChooserPanel('media')
]
I'm using a custom media model by the way. That's where that get_media_model_string()
comes from.
π thanks, that will make troubleshooting much easier.
In the meantime you might be able to do what my project does, although I'm not sure of the implications:
from wagtailmedia.widgets import AdminMediaChooser
[...]
content_panels = Page.content_panels + [
[...]
FieldPanel('media', widget=AdminMediaChooser),
]
If that's an issue with 0.3.0 I'm sorry it fell through the cracks. Tried my best to review each and every bit of API of wagtailmedia, but I must've missed that one.
Hey @thibaudcolas, using AdminMediaChooser
still gives the same error.
I guess for now just using FieldPanel should be enough.
Thank you!
Ah that's really strange π are you sure this isn't just a caching issue with a CDN / the browser?
I'll try both options and report back.
hmm not sure it's a CDN issue since it's on localhost, I'll check the browser
The fix for #34 (i.e #40) is on the right path
MediaChooserPanel
needs to be:
class MediaChooserPanel(BaseChooserPanel):
object_type_name = 'media'
def widget_overrides(self):
return {self.field_name: AdminMediaChooser}
The one thing missing from that PR is a shim or deprecation for BaseMediaChooserPanel
for projects that currently use it. Unless we cut a new release with the appropriate upgrade considerations @thibaudcolas
Context: Slack #support reply. Diff for mentioned repo:
master...solarissmoke:wagtail25#diff-7bea8da4a64ce9c5452abd60428fa2c9R8
@Aesirry also try to run collectstatic
on your local environment to make sure this isn't the issue. We did move lots of JS code around as part of the 0.3.0 compatibility changes.
@thibaudcolas I tried creating a brand new site (the previous one had many modifications, including templates). There is another error when I try to use a RichTextField and a media field with the AdminMediaChooser
.
Again for this site the versions are the same:
- python 3.7.2
- django 2.2.1
- wagtail 2.5.1
- wagtailmedia 0.3.0
here's the model:
class HomePage(Page):
author = models.CharField(max_length=255, blank=True, null=True)
date = models.DateField("Post date", blank=True, null=True)
body = RichTextField(blank=True, null=True)
media = models.ForeignKey(
'wagtailmedia.Media',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
content_panels = Page.content_panels + [
FieldPanel('author'),
FieldPanel('date'),
FieldPanel('body'),
FieldPanel('media', widget=AdminMediaChooser),
]
I made another model without a media
field and the RichTextField works normally.
here's the code for that:
class RandomPage(Page):
author = models.CharField(max_length=255, blank=True, null=True)
date = models.DateField("Post date", blank=True, null=True)
body = RichTextField(blank=True, null=True)
content_panels = Page.content_panels + [
FieldPanel('author'),
FieldPanel('date'),
FieldPanel('body')
]
I hope this can give you a hint in the right direction π
@thibaudcolas I spoke over slack with the Wagtail support and it turns out that this is actually an issue with wagtail.
Also using FieldPanel('media', widget=AdminMediaChooser)
works fine now. You might want to change the example in the ReadMe
I've updated the docs as part of #57, sorry you ran into this @Aesirry.