Skip to content

Commit

Permalink
Merge pull request #71 from xalien10/docs/customise-export-queryset
Browse files Browse the repository at this point in the history
Documentation added for customising model queryset for celery export job
  • Loading branch information
timthelion authored Apr 8, 2022
2 parents 69ec0a5 + 1ecd38a commit 69b4838
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

3 comments on commit 69b4838

@xalien10
Copy link
Collaborator

@xalien10 xalien10 commented on 69b4838 Apr 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timthelion It would be great if you can share when you're going to make the release of 1.2. I appreciate your kind and quick response.

@timthelion
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, do you know you can pull in git tags with pip? You don't need to wait for a release...

@xalien10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much !!! It was much needed for me. 😊 Now I can export according to my needs

Please sign in to comment.