Skip to content

Commit

Permalink
Documentation added for customising model queryset for celery export job
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmudul Hasan committed Apr 8, 2022
1 parent 69ec0a5 commit 1ecd38a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,18 @@ As with imports, a fully configured example project can be found in the `example
create_export_job_action,
)

3. Done!
3. To customise export queryset you need to add `get_export_queryset` to the `ModelResource`.
::

class WinnersResource(ModelResource):
class Meta:
model = Winner

def get_export_queryset(self):
"""To customise the queryset of the model resource with annotation override"""
return self.Meta.model.objects.annotate(device_type=Subquery(FCMDevice.objects.filter(
user=OuterRef("pk")).values("type")[:1])
4. Done!

Performing exports with celery
------------------------------
Expand Down

0 comments on commit 1ecd38a

Please sign in to comment.