I’m just learning Django, and I’m trying to set up the admin area for a new project.
I’m getting the following error:
type object 'StopInline' has no attribute 'date_hierarchy'
Here is the model:
from django.db import models
class Line(models.Model):
name = models.CharField(max_length=200)
class Lap(models.Model):
line = models.ForeignKey(Line)
order = models.IntegerField()
class Stop(models.Model):
name = models.CharField(max_length=200)
line = models.ForeignKey(Line)
lap = models.ForeignKey(Lap)
order = models.IntegerField()
departsHour = models.IntegerField()
departsMinute = models.IntegerField()
And here is the admin.py:
from schedule.models import Line, Stop
from django.contrib import admin
class StopInline(admin.TabularInline):
model = Stop
extra = 3
class LineAdmin(admin.ModelAdmin):
model = Line
inlines = [StopInline]
admin.site.register(Line, StopInline)
I don’t have anything related to a date, so I’m not sure what’s going on. Thanks!
should do it.
registerexpects models andModelAdmins. You were trying to register to adminLinewithStopInlinewhich confused it.EDIT I realized this about 45 seconds afterwards. You don’t need to register StopInline since it’s ‘included’ in LineAdmin.