You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-10Lines changed: 28 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -343,6 +343,13 @@ class TimeSeriesSerializer(serializers.ModelSerializer):
343
343
model = TimeSeries
344
344
fields ='__all__'
345
345
346
+
# Optional - see options below
347
+
data_wizard = {
348
+
'header_row': 0,
349
+
'start_row': 1,
350
+
'show_in_list': True,
351
+
}
352
+
346
353
# Use default name & serializer
347
354
data_wizard.register(TimeSeries)
348
355
@@ -352,6 +359,16 @@ data_wizard.register("Time Series - Custom Serializer", TimeSeriesSerializer)
352
359
353
360
At least one serializer or model should be registered in order to use the wizard. Note the use of a human-friendly serializer label when registering a serializer. This name should be unique throughout the project, but can be changed later on without breaking existing data. (The class path is used as the actual identifier behind the scenes.)
354
361
362
+
### Serializer Options
363
+
364
+
Data Wizard also supports custom configuration by setting a `data_wizard` attribute on the `Meta` class of the serializer. The following options are supported.
365
+
366
+
name | default | notes
367
+
--|--|--
368
+
`header_row` | 0 | Specifies the first row of the spreadsheet that contains column headers. If this is greater than 0, the space above the column headers will be scanned for anything that looks like a one-off "global" value intended to be applied to every row in the imported data.
369
+
`start_row` | 1 | The first row of data. If this is greater than `header_row + 1`, the column headers will be assumed to span multiple rows. A common case is when parameter hames are on the first row and units are on the second.
370
+
`show_in_list` | `True` | **New in 1.2**. If set to `False`, the serializer will be available through the API but not listed in the wizard views. This is useful if you have a serializer that should only be used during fully automated workflows.
371
+
355
372
## Custom Data Sources
356
373
357
374
Django Data Wizard uses [wq.io] to determine the source columns present on the spreadsheet or other data source. Django Data Wizard can use any Django model instance as a source for its data, provided there is a registered loader that can convert the source model into a [wq.io] iterable. Data Wizard provides two out-of-the the box loaders, [FileLoader] and [URLLoader], that can be used with the provided models in `data_wizard.sources` (`FileSource` and `URLSource`, respectively).
@@ -382,7 +399,17 @@ from .models import FileModel
You have to add a custom Admin model to add the Import action in the admin panel for your model.
402
+
403
+
If you have a generic loader that can work with multiple source models, you can also set the default loader globally:
404
+
405
+
```python
406
+
# myapp/settings.py
407
+
DATA_WIZARD= {
408
+
'LOADER': 'myapp.loaders.FileLoader'
409
+
}
410
+
```
411
+
412
+
As of Django Data Wizard 1.2, you should register a custom `ModelAdmin` class to add the Import action in the admin panel for your model.
386
413
387
414
```python
388
415
# myapp/admin.py
@@ -397,15 +424,6 @@ class FileModelAdmin(ImportActionModelAdmin):
397
424
pass
398
425
```
399
426
400
-
You can also set the default loader globally:
401
-
402
-
```python
403
-
# myapp/settings.py
404
-
DATA_WIZARD= {
405
-
'LOADER': 'myapp.loaders.FileLoader'
406
-
}
407
-
```
408
-
409
427
### Custom Loader
410
428
The default loaders support any file format supported by [wq.io] (Excel, CSV, JSON, and XML). Additional formats can be integrating by creating a [custom wq.io class] and then registering it with the wizard. For example, the [Climata Viewer] uses Django Data Wizard to import data from [climata]'s wq.io-based web service client. To do this, extend `data_wizard.loaders.BaseLoader` with a custom `load_io()` function that returns the data from wq.io, as in the example below.
0 commit comments