Skip to content

Commit 9a8facd

Browse files
authored
Add note about bulk_create to README
1 parent c84042f commit 9a8facd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ jobs in the "NEW" or "READY" states will be returned.
285285

286286
**Important:** If you misspell or provide a queue name which does not have any jobs, a depth of 0 will always be returned.
287287

288+
### Gotcha: `bulk_create`
289+
290+
Because the `Job` model has logic in its `save` method, and because `save` doesn't get called when using `bulk_create`, you can't easily use `bulk_create` to create multiple `Job` instances at the same time.
291+
292+
If you really need to do this, you should be able to get it to work by using `django_dbq.tasks.get_next_task_name` to compute the next task name from the `name` of the job, and then use that value to populate the `next_task` field on each of the unsaved `Job` instances before calling `bulk_create`. Note that if you use the approach, the job's `creation_hook` will not be called.
293+
288294
## Testing
289295

290296
It may be necessary to supply a DATABASE_PORT environment variable.

0 commit comments

Comments
 (0)