How to export "down" on Django admin?
I need to export the author and each of his books, but the author just export the author. I managed to make the "book" maintainer export the author, but for every book it appears the author in every line. I have the "tabular in line" that means if I pick and author it shows every book in the admin page, so I know it's possible to do it but I don't know why, help!
I have Author, Country and Book, and looks like this, models.py:
class Author(models.Model):
name = models.CharField(max_length=100)
def __str__(self):
return self.name
class Country(models.Model):
name = models.CharField(max_length=100)
def __str__(self):
return self.name
class Book(models.Model):
name = models.CharField('Book name', max_length=100)
author = models.ForeignKey(Author, blank=True, null=True)
author_email = models.EmailField('Author email', max_length=75, blank=True)
imported = models.BooleanField(default=False)
published = models.DateField('Published', blank=True, null=True)
price = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
country = models.ForeignKey(Country, blank=True)
The admin.py:
admin.site.register(Book)
admin.site.register(Country)
class BookInline(admin.TabularInLine):
model = Book
max_num = 0
can_delete = False
@admin.register(Author)
class AdminAuthor(ImportExportActionModelAdmin):
list_display = (name)
inlines = [
BookInline,
]
class Meta:
model = Book
It's not a many to many relationship, its one to many, so plis help me to make it look Something like this as a django admin action:
+--- Author -----+
| Shakeitspeare |
+----------- Book ---------------------+--- Published----+
| Romeo and Sexyjulliette | 1986 |
| She-Hamlet | 2020 |
| Two Gentlemen and one cup in Verona | 2008 |
I'm using https://django-import-export.readthedocs.io/en/latest/index.html#django-import-export But it shows me how to do it from books to author...