Skip to content

Instantly share code, notes, and snippets.

@mgrdcm
Last active August 15, 2018 00:14
Show Gist options
  • Save mgrdcm/f6e62b7eac741e93082a82a91138b1f1 to your computer and use it in GitHub Desktop.
Save mgrdcm/f6e62b7eac741e93082a82a91138b1f1 to your computer and use it in GitHub Desktop.
"""
workaround until https://github.com/jazzband/django-embed-video/pull/88 gets released
just import from this and use PR88AdminVideoMixin in place of AdminVideoMixin
"""
import inspect
from embed_video.admin import AdminVideoMixin, AdminVideoWidget
from embed_video.fields import EmbedVideoField
class PR88AdminVideoWidget(AdminVideoWidget):
def render(self, name, value='', attrs=None, size=(420, 315), renderer=None):
return super(PR88AdminVideoWidget, self).render(name, value, attrs)
class PR88AdminVideoMixin(AdminVideoMixin):
def formfield_for_dbfield(self, db_field, **kwargs):
argspec = inspect.getargspec(AdminVideoWidget.render)
# If upstream hasn't been fixed yet and we need to use the PR88 version of the widget...
if 'renderer' not in argspec.args and isinstance(db_field, EmbedVideoField):
return db_field.formfield(widget=PR88AdminVideoWidget)
return super(PR88AdminVideoMixin, self)\
.formfield_for_dbfield(db_field, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment