Import Wizard

Style-agnostic import wizard component.

python 7 params

Preview

1Upload
2Map Fields
3Preview

Drag & drop or click to upload

Accepted: .csv

Usage

views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import ImportWizard


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = ImportWizard()

    @event_handler()
    def upload_file(self, value=None, **kwargs):
        ...  # write to self.component; the re-render carries it

    @event_handler()
    def import_data(self, value=None, **kwargs):
        ...  # write to self.component; the re-render carries it
my_template.html
django
{{ component }}

Events this component sends to the view: upload_file, import_data.

Parameters

NameTypeDefault
accepted_formatsstr'.csv'
model_fieldslist | NoneNone
eventstr — renames the event; identity is `name`'import_data'
stepstr'upload'
upload_eventstr — renames the event; identity is `name`'upload_file'
custom_classstr''
**kwargs— passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state
Source & styles
FilePathNotes
moduledjust.components.components.import_wizardSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 10 of this component's classes at line 1901, 1902, 1903, 1904, 1906, 1908, 1909, 1910, 2439, 2440. Override those rules, or the custom properties they read, in a stylesheet loaded after it.