Using an abstract class in a template for a detailed item based on common classes in Django

I just started working with general concepts based on a class and love it. I have one struggle that I still can’t solve.

I have one abstract class called a group, and two subsidiaries and a Bond. (I simplified my example). These are my models.py:

models.py

class Group(BaseModel):                                                         
    name = models.CharField(max_length=30, unique=True)                                                

    class Meta:                                                                    
        abstract = True                                                            


class Company(Group):                                                              
    def __str__(self):                                                             
        return "Company " + self.name                                              


class Bond(Group):                                                                 
    def __str__(self):                                                             
        return "Bond " + self.name 

group_detail.html group.name. , company.name bond.name, . , , . , , ?

+4
2

Group , , . Company Bond Company Bond .

Company Bond , , . , , , Company Bond , , , .

+3

object , {{ object.name }}.

0

Source: https://habr.com/ru/post/1618720/


All Articles