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, **kwargs):
        self.component.step = 'map'

    @event_handler()
    def import_data(self, **kwargs):
        pass  # your app acts on 'import_data'; no component state moves
my_template.html
django
{{ component }}

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

Parameters

NameTypeDefaultDescription
accepted_formatsstr'.csv'Comma-separated accepted file extensions
model_fieldslist | NoneNoneList of field dicts with id, label
eventstr — renames the event; identity is `name`'import_data'djust event for triggering import
stepstr'upload'Current wizard step (upload, map, preview)
upload_eventstr — renames the event; identity is `name`'upload_file'djust event for file upload
custom_classstr''Additional CSS classes
**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 1928, 1929, 1930, 1931, 1933, 1935, 1936, 1937, 2542, 2543. Override those rules, or the custom properties they read, in a stylesheet loaded after it.