Django Admin tables not displaying correctly

511 views Asked by At

django admin incorrectly displaying tables?

Has anyone seen this before? I've tried making new apps, projects, etc.

All thats in my admin.py file is:

from django.contrib import admin
from . models import UserProfile, Tribe, Membership

# Register your models here.

admin.site.register(Tribe)
admin.site.register(Membership)
admin.site.register(UserProfile)

I've not got any static files or css in the app..?

1

There are 1 answers

0
AudioBubble On BEST ANSWER

Create a class that inherit admin.ModelAdmin, update the fields to be shown in the list_display tuple, and register TribeAdmin instead of Tribe. Do the same for the rest.

from django.contrib import admin
from . models import UserProfile, Tribe, Membership

# Register your models here.

class TribeAdmin(admin.ModelAdmin):
    list_display = ('field_1', 'field_2',)

admin.site.register(Tribe, TribeAdmin)
# admin.site.register(Membership)
# admin.site.register(UserProfile)

For all the available options, have a look at the documentation or an easy to understand beginner tutorial from the DjangoBook (please note its for an outdated Django Version, but fields works with Django 1.8)

With Django 1.8 you can use.

@admin.register(Tribe)
class TribeAdmin(admin.ModelAdmin):
    list_display = ('field',)