Skip to content

Commit 69b4838

Browse files
authored
Merge pull request #71 from xalien10/docs/customise-export-queryset
Documentation added for customising model queryset for celery export job
2 parents 69ec0a5 + 1ecd38a commit 69b4838

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,18 @@ As with imports, a fully configured example project can be found in the `example
121121
create_export_job_action,
122122
)
123123

124-
3. Done!
124+
3. To customise export queryset you need to add `get_export_queryset` to the `ModelResource`.
125+
::
126+
127+
class WinnersResource(ModelResource):
128+
class Meta:
129+
model = Winner
130+
131+
def get_export_queryset(self):
132+
"""To customise the queryset of the model resource with annotation override"""
133+
return self.Meta.model.objects.annotate(device_type=Subquery(FCMDevice.objects.filter(
134+
user=OuterRef("pk")).values("type")[:1])
135+
4. Done!
125136

126137
Performing exports with celery
127138
------------------------------

0 commit comments

Comments
 (0)