Skip to content

Commit b9640f3

Browse files
committed
update docs for 1.2.0 [skip ci]
1 parent 6ec6c2f commit b9640f3

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,13 @@ class TimeSeriesSerializer(serializers.ModelSerializer):
343343
model = TimeSeries
344344
fields = '__all__'
345345

346+
# Optional - see options below
347+
data_wizard = {
348+
'header_row': 0,
349+
'start_row': 1,
350+
'show_in_list': True,
351+
}
352+
346353
# Use default name & serializer
347354
data_wizard.register(TimeSeries)
348355

@@ -352,6 +359,16 @@ data_wizard.register("Time Series - Custom Serializer", TimeSeriesSerializer)
352359

353360
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.)
354361

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+
355372
## Custom Data Sources
356373

357374
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
382399

383400
data_wizard.set_loader(FileModel, "myapp.loaders.FileLoader")
384401
```
385-
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.
386413

387414
```python
388415
# myapp/admin.py
@@ -397,15 +424,6 @@ class FileModelAdmin(ImportActionModelAdmin):
397424
pass
398425
```
399426

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-
409427
### Custom Loader
410428
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.
411429

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def readme():
6565
'Framework :: Django :: 1.11',
6666
'Framework :: Django :: 2.0',
6767
'Framework :: Django :: 2.1',
68+
'Framework :: Django :: 2.2',
6869
'Topic :: Scientific/Engineering :: GIS',
6970
'Topic :: Database :: Database Engines/Servers',
7071
],

0 commit comments

Comments
 (0)