1👍
✅
The problem is the missing :
:
class HouseReport(admin.ModelAdmin):
^
Speaking about the task you’ve initially wanted to solve, check the InlineModelAdmin
classes:
The admin interface has the ability to edit models on the same page as
a parent model. These are called inlines.
Add this to the admin.py
:
from django.contrib import admin
from housing.models import HouseInformation, HouseReport
class HouseReportInline(admin.TabularInline):
model = HouseReport
class HouseAdmin(admin.ModelAdmin):
inlines = [
HouseReportInline,
]
admin.site.register(HouseInformation, HouseAdmin)
And you will see the House
information and all of the HouseReport
s associated with a House
on the House
admin page.
1👍
You forgot the : after the class definition in line 5
class HouseReport(admin.ModelAdmin):
And you have to write
...
list_display = ('the_house',)
...
notice the trailing comma? It tells python, that it should create a tuple
- [Answered ]-How can I switch my Django project's database engine from Sqlite to MySQL?
- [Answered ]-Signal for M2M changed on a through field
- [Answered ]-URL Query Param Djangorestframework
Source:stackexchange.com