Sometimes, we want to write a init function to be used in a Python Django model.
In this article, we’ll look at how to write a init function to be used in a Python Django model.
How to write a init function to be used in a Python Django model?
To write a init function to be used in a Python Django model, we can pass in named arguments into the model class’ built in __init__
function.
For instance, we write
p = User(name="Fred", email="fred@example.com")
to create a User
instance by passing in the name
and email
arguments.
Conclusion
To write a init function to be used in a Python Django model, we can pass in named arguments into the model class’ built in __init__
function.