[Django]-__init__() takes exactly 1 argument (7 given)

7👍

The problem is in

class Supplier(Person):

    def __init__(self):
        super(Supplier, self).__init__()

Have a look at django.db.models.Model source code

class Model(six.with_metaclass(ModelBase)):
    _deferred = False

    def __init__(self, *args, **kwargs):

Your __init__ function get only the instance itself as argument, but django is passing probably more arguments. That’s why you need to use *args, **kwargs.

To better understand *args and **kwargs you can have a look at this

4👍

By fixing this error, update the Supplier model by adding the parameter *args, **kwargs

class Supplier(Person):

    def __init__(self, *args, **kwargs):
        super(Supplier, self).__init__(*args, **kwargs)

Leave a comment