Open chkur opened 1 week ago
Thanks for raising. It looks like a valid bug, because when I try in the example app, I can see 'Author Name' in the output, but it doesn't appear in the exported csv file.
class BookResource(ModelResource):
name = Field(attribute="author__name", column_name="Author Name")
class Meta:
model = Book
'Author Name' not in the output:
The workaround is to define the field (referenced by attribute) in the fields
list:
class Meta:
fields = ("author__name", )
model = Book
Then the field will appear in the export.
Docs for reference.
Note if I reference by declared field name, then it appears in the output list, but not in the csv:
fields = ("name", )
(csv is empty file)
This was fixed in #1903 (which will be released in v4.2.0). If you use the main branch the issue should be fixed. I added a test in #1955.
Not actually fixed. The test added in #1955 shows that the wrong field is exported (the book name is exported, not the author name).
This is the default export output in v3:
Author Name,id,author,author_email,imported,published,published_time,price,added,categories
George R. R. Martin,11,11,martin@got.com,0,1996-08-01,21:00:00,25.00,,1
The POST parameters don't identify the Author Name field
author__name
: author__name = Field(attribute='author__name', column_name='Author Name' )
fields
:
fields = ("author__name",)
(although this writes the column name as author__name
)
Declare the field as 'Author Name' and it will export ok:
fields = ("Author Name",)
Describe the bug When export with admin - get no foreign keys in exported file. It worked earlier. FK example:
To Reproduce Steps to reproduce the behavior:
Versions (please complete the following information):
Expected behavior Export with admin button must export all fields described for export, including foreignkeys
Additional context Export in admin works in 3.3.9, installed that version.