2021-12-10

Tech Programing

程式人小天地

How display 2 model tables on 1 admin page

1 min read


I have a general error model and “child models” I want to display all the tables of child models on the error page.
Example:

#models.py

class Errors(models.Model):
    class Meta:
        verbose_name = "Errors"

class Error1(models.Model):
    error1 = models.TextField(('Error1'), blank=True, null=True)

class Error2(models.Model):
    error2 = models.TextField(('Error2'), blank=True, null=True)

class Error3(models.Model):
    error3 = models.TextField(('Error3'), blank=True, null=True)

#admin.py

@admin.register(Errors)
class ErrorsAdmin(admin.ModelAdmin):
    change_list_template="admin/errors/errors.html"
    ...



Source link

資料來源:Stackoverflow

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *