thomst / django-admin-csvexport

A django-admin-action to export models as csv
BSD 3-Clause "New" or "Revised" License
17 stars 9 forks source link

Multiple relations of the same model seems not supported #6

Open danaki opened 2 years ago

danaki commented 2 years ago
class VwUiPosting(models.Model):
    posting_id = models.BigIntegerField(primary_key=True)
    posting_currency = models.ForeignKey(Currency, models.DO_NOTHING, blank=True, null=True, related_name='backend_posting_vw_ui_posting_currency')
    fee_currency = models.ForeignKey(Currency, models.DO_NOTHING, blank=True, null=True, related_name='backend_posting_vw_ui_fee_currency')
class VwUiPostingAdmin(ModelAdmin):
    actions = [csvexport]
    csvexport_export_fields = [
        'posting_id',
        'posting_currency.currency_code',
        'fee_currency.currency_code',
    ]
    csvexport_selected_fields = [
        'posting_id',
        'posting_currency.currency_code',
        'fee_currency.currency_code',
    ]

Field 'fee_currency.currency_code' appears two times in the resulting csv.

thomst commented 2 years ago

Hi @danaki . Thanks a lot for your contribution. Actually I can't reproduce the error you described. I've build a test that sould cover the issue as I understood it and pushed it into the branch issue6. But it just passes fine.

Could you please clarify the misbehavior that you are observing. And would it be able for you to overwork the my test case so that it actually cover your issue?

ignaciora commented 1 year ago

@thomst hi! I have the same issue. Your issue6's test model is not representing the same model descripted by @danaki where "posting_currency" and "fee_currency" are foreing keys of the same model.