Skip to content

Commit 1a21263

Browse files
authored
update wq integration docs (see #28)
1 parent 2be67f3 commit 1a21263

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -560,32 +560,34 @@ Finally, run celery with `celery -A myproject`. You may want to use celery's [d
560560
561561
## wq Framework integration
562562

563-
The Django Data Wizard has built-in support for integration with the [wq framework]. Configuration is mostly the same, except that you do not need to add `"data_wizard.urls"` to your urls.py as the wizard will register itself with [wq.db] instead.
563+
The Django Data Wizard has built-in support for integration with the [wq framework]. On the server, configuration is mostly the same, except that you do not need to add `"data_wizard.urls"` to your urls.py as the wizard will register itself with [wq.db] instead.
564564

565-
Data Wizard includes mustache templates for each of the above tasks to integrate with the wq.app UI. Be sure to enable the [wq/progress.js] plugin for use with the `run_auto.html` and `run_data.html` template. You could allow the user to initiate an import run by adding the following to the detail HTML for your model:
565+
Data Wizard provides mustache templates for each of the above tasks to integrate with the wq.app UI. These are rendered on the server and do not need to be included in your JavaScript build. However, you should install the [@wq/progress] plugin via NPM and register it with [@wq/app].
566+
567+
```javascript
568+
// src/index.js
569+
import app from '@wq/app';
570+
import progress from '@wq/progress';
571+
572+
app.use(progress);
573+
app.init(config).then(...);
574+
```
575+
576+
Once everything is set up, add the following `<form>` to the detail template that wq generates for your source model. Note that you will need to add this `<form>` manually even if the source model is one of `data_wizard.sources`. After adding the form, be sure to skip template regeneration for the source model.
566577

567578
```html
568-
<!-- filemodel_detail.html -->
579+
<!-- filesource_detail.html -->
569580
<h1>{{label}}</h1>
570581
<a href="{{rt}}/media/{{file}}" rel="external">Download File</a>
571582

572-
<form action="{{rt}}/datawizard/" method="post" data-ajax="true" data-wq-json="false">
583+
<form action="{{rt}}/datawizard/" method="post">
573584
{{>csrf}}
574-
<input type="hidden" name="content_type_id" value="myapp.filemodel">
585+
<input type="hidden" name="content_type_id" value="sources.filesource">
575586
<input type="hidden" name="object_id" value="{{id}}">
576587
<button type="submit">Import Data from This File</button>
577588
</form>
578589
```
579590

580-
```javascript
581-
// myapp/main.js
582-
define(['wq/app', 'wq/progress', ...],
583-
function(app, progress, ...) {
584-
app.use(progress);
585-
app.init(config).then(...);
586-
});
587-
```
588-
589591
[IterTable]: https://github.com/wq/itertable
590592
[Django REST Framework]: http://www.django-rest-framework.org/
591593
[natural keys]: https://github.com/wq/django-natural-keys
@@ -627,3 +629,6 @@ function(app, progress, ...) {
627629
[naturalkey_wizard]: https://github.com/wq/django-data-wizard/blob/master/tests/naturalkey_app/wizard.py
628630
[eav_wizard]: https://github.com/wq/django-data-wizard/blob/master/tests/eav_app/wizard.py
629631
[management command]: https://docs.djangoproject.com/en/2.1/ref/django-admin/
632+
633+
[@wq/progress]: https://github.com/wq/django-data-wizard/tree/master/packages/progress
634+
[@wq/app]: https://wq.io/docs/app-js

0 commit comments

Comments
 (0)