[Fixed]-How to assign a model instance to a class property in django

1👍

Your SingleLeagueCompetition class should inherit from BaseCompetition, like this:

class BaseCompetition:
    def __init__(self, company):
        self.company = company
class SingleLeagueCompetition(BaseCompetition):
    def __init__(self, company):
        super().__init__(company)

also instead of call constructor by using parent class BaseCompetition._init_ you can use super to bind it in child.

More reference consult: https://docs.python.org/3.4/library/functions.html#super

Leave a comment