Getting Typeerror: _Init_() Missing 1 Required Positional Argument: 'On_Delete' When Trying to Add Parent Table After Child Table with Entries

Getting TypeError: __init__() missing 1 required positional argument: 'on_delete' when trying to add parent table after child table with entries

You can change the property categorie of the class Article like this:

categorie = models.ForeignKey(
'Categorie',
on_delete=models.CASCADE,
)

and the error should disappear.

Eventually you might need another option for on_delete, check the documentation for more details:

Arguments -- Model field reference -- Django documentation

As you stated in your comment, that you don't have any special requirements for on_delete, you could use the option DO_NOTHING:

# ...
on_delete=models.DO_NOTHING,
# ...

__init__() missing 1 required positional argument

You're receiving this error because you did not pass a data variable to the DHT constructor.

aIKid and Alexander's answers are nice but it wont work because you still have to initialize self.data in the class constructor like this:

class DHT:
def __init__(self, data=None):
if data is None:
data = {}
else:
self.data = data
self.data['one'] = '1'
self.data['two'] = '2'
self.data['three'] = '3'
def showData(self):
print(self.data)

And then calling the method showData like this:

DHT().showData()

Or like this:

DHT({'six':6,'seven':'7'}).showData()

or like this:

# Build the class first
dht = DHT({'six':6,'seven':'7'})
# The call whatever method you want (In our case only 1 method available)
dht.showData()

Error when trying to override __init__() : TypeError: __init__() takes 1 positional argument but 2 were given

Every class init method has self as an argument to allow adding attributes to this newly created instance of the class.
Calling super().__init__(self, **kwargs) in Child.init results to Base(Child, **kwargs). The base constructor takes only one argument so an error is raised.

TypeError: __init__() missing 2 required positional arguments: 'client_socket' and 'statusMessage'

class SimpleClient:
def __init__(self, client_socket, statusMessage):

Your class taking two arguments, but when you call it;

client = SimpleClient()

You didn't write any arguments. So you have to put 2 arguments they may be None.



Related Topics



Leave a reply



Submit