Skip to content

widgets

django_spire.file.widgets

MultipleWidget

Bases: Widget

Source code in django_spire/file/widgets.py
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

needs_multipart_form = True class-attribute instance-attribute

template_name = 'django_spire/file/widget/multiple_file_widget.html' class-attribute instance-attribute

value_from_datadict

Source code in django_spire/file/widgets.py
def value_from_datadict(self, data, files, name):
    return json.loads(data.get(f'{name}_data'))

render

Source code in django_spire/file/widgets.py
def render(self, name, value, attrs=None, renderer=None):
    context = self.get_context(name, value, attrs)
    template = loader.get_template(self.template_name).render(context)
    return mark_safe(template)

SingleFileWidget

Bases: Widget

Source code in django_spire/file/widgets.py
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

needs_multipart_form = True class-attribute instance-attribute

template_name = 'django_spire/file/widget/single_file_widget.html' class-attribute instance-attribute

value_from_datadict

Source code in django_spire/file/widgets.py
def value_from_datadict(self, data, files, name) -> dict:
    return json.loads(data.get(f'{name}_data'))

render

Source code in django_spire/file/widgets.py
def render(self, name, value, attrs=None, renderer=None):
    context = self.get_context(name, value, attrs)
    template = loader.get_template(self.template_name).render(context)
    return mark_safe(template)