benkonrath / django-csv-export-view

Django class-based view for CSV exports
BSD 3-Clause "New" or "Revised" License
19 stars 3 forks source link

Behavior on non given references #20

Open frlan opened 1 month ago

frlan commented 1 month ago

Scenario: I wanted to create a easy export view for a list of orders including some data like addresses and bank accounts data etc. Bank account data are stored in a dedicated model so references are used like field = ("order__user__bankaccount")-- However, when there is no bank account connected (which makes sense from model point of view) that I'm running into an error.

Of course I could modify get_queryset() with some if-else-magic -- But honestly I'd like to avoid that and suggesting to add some magic that either keep this fields empty or make it configurable. Something like a left outer join in SQL without a fitting dataset.

benkonrath commented 3 weeks ago

Thanks for posting this. Could you post the modelling your using the causing the problems. Just a simple version with the relationships. Thanks.