When entering background information of django database model and xadmin, second-level classification, the first-level classification is selected first, and the second-level classification is selected.

I want to make a book classification
there are two categories:

(id(), name)
(id(), fist_type(), name)

there is also a book information table

()

when you want to add book information in the xadmin background, select the first category first, and then select the second category

from django.db import models


-sharp Create your models here.
class BookFirstType(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField("", max_length=200)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = ""
        verbose_name_plural = verbose_name


class BookSecondType(models.Model):
    id = models.AutoField(primary_key=True)
    first_type = models.ForeignKey(BookFirstType, on_delete=models.CASCADE, verbose_name="")  -sharp , 
    name = models.CharField("", max_length=200)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = ""
        verbose_name_plural = verbose_name


class BookInfo(models.Model):
    id = models.AutoField(primary_key=True)
    second_type = models.ForeignKey(BookSecondType, on_delete=models.CASCADE, verbose_name="")
    name = models.CharField("", max_length=200)
    author = models.CharField("", max_length=200)
    note = models.TextField("", max_length=10000)
    money = models.CharField("", max_length=200)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = ""
        verbose_name_plural = verbose_name
Mar.03,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3505b-2bf58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3505b-2bf58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?