class Street(MPTTModel):
name = models.CharField(max_length=100)
parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='streets')
class MPTTMeta:
order_insertion_by = ['name']
def __str__(self):
return self.name
class House(MPTTModel):
name = models.CharField(max_length=100)
parent = TreeForeignKey(Street, on_delete=models.CASCADE, null=True, blank=True, related_name='houses')
class MPTTMeta:
order_insertion_by = ['name']
def __str__(self):
return self.name
class TechRoom(MPTTModel):
name = models.CharField(max_length=100)
parent = TreeForeignKey(House, on_delete=models.CASCADE, null=True, blank=True, related_name='tech_rooms')
class MPTTMeta:
order_insertion_by = ['name']
def __str__(self):
return self.name
also I have admin.py:
from django.contrib import admin
from django_mptt_admin.admin import DjangoMpttAdmin
from .models import Street, House, TechRoom
@admin.register(Street)
class StreetAdmin(DjangoMpttAdmin):
pass
@admin.register(House)
class HouseAdmin(DjangoMpttAdmin):
pass
@admin.register(TechRoom)
class TechRoomAdmin(DjangoMpttAdmin):
pass
But the problem is I cannot see the tree, only regular models with Foreign Keys. Is it possible to show and edit these models as a tree using django-mptt-admin?
I have a tree with nested models like this:
also I have admin.py:
But the problem is I cannot see the tree, only regular models with Foreign Keys. Is it possible to show and edit these models as a tree using django-mptt-admin?
Thanks in advance.