I have models and their admin code below. The question is, how can I display the first three tag
books in the list_display
property? I can show tags while editing a book, but I would like its tags to be in tags when the book is listed in the admin panel.
models.py
class Book(models.Model): name = models.CharField(max_length=1000) def __unicode__(self): return self.name class BookTag(models.Model): name = models.CharField(max_length=1000) book = models.ForeignKey(Book,null=False,blank=False) def __unicode__(self): return self.name
admin.py
class BookTagInline(admin.TabularInline): model = JobTitleTag class BookAdmin(admin.ModelAdmin): list_display = ('name') inlines = [ BookTagInline, ] admin.site.register(Book,BookAdmin)
Could you give me some suggestion? Thanks
source share