Answer the question
In order to leave comments, you need to log in
Why are objects not showing up in django admin?
There is a model and its Admin:
class InviteBonus(models.Model):
total = models.DecimalField(verbose_name='cумма платежа', blank=False, null=False, decimal_places=2, max_digits=12)
use_date = models.DateField(verbose_name='дата платежа', blank=False)
inviter = models.ForeignKey(TreeNode, verbose_name='пригласивший', related_name='bonuses')
newbie = models.ForeignKey(TreeNode, verbose_name='приглашённый', related_name='awards')
paid = models.BooleanField(default=False, verbose_name='выплачено')
five_per_period = models.BooleanField(default=False, verbose_name='пять за период')
line = models.PositiveIntegerField(verbose_name='линия')
class InviteBonusAdmin(admin.ModelAdmin):
list_display = ('id', 'inviter', 'line', 'newbie', 'use_date', 'total', 'paid')
list_filter = ('use_date', )
search_fields = ('inviter__company_id', )
Answer the question
In order to leave comments, you need to log in
This happens if the output of any of the fields in the table throws an exception. You yourself noted that when displaying only one id in the list_display list , everything is fine. You need to add one field to list_display and understand which of the fields gives an error.
This happened to me when using calculated fields, that is, the names of functions in list_display , if these functions threw an exception. You don't seem to have any. So this is just a guess.
I would guess something is wrong with TreeNode.__unicode__ The admin
calls this method to display foreign keys
did you do admin.site.register?
from django.contrib import admin
from .models import InviteBonus, TreeNode
class InviteBonusAdmin(admin.ModelAdmin):
list_display = ('id', 'inviter', 'line', 'newbie', 'use_date', 'total', 'paid')
list_filter = ('use_date', )
search_fields = ('inviter__company_id', )
admin.site.register(InviteBonus, InviteBonusAdmin)
admin.site.register(TreeNode)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question