Do all models in Django basically have init constructors that assign to object variables
<p>Suppose I have something like this</p>

<pre><code>class Album(models.Model):
    artist = models.CharField(max_length=128, unique=True)
    title = models.CharField(max_length=128, unique=True)
</code></pre>

<p>Now I can do this</p>

<pre><code>inst = Album(artist="Shania Twain",title="blah")
</code></pre>

<p>Since I have not studied how model classes are created under the hood , I am curious do all the model classes have an init constructor as well ? For instance </p>

<pre><code>class Album(models.Model):
    artist = models.CharField(max_length=128, unique=True)
    title = models.CharField(max_length=128, unique=True)
    def __init__(self,artist):
            Album.artist = artist
            ..........
            ..........
</code></pre>

<p>Please let me know if this makes sense.</p>

<p>Yes it has, but is not recommend to override it.</p>

<p>You can do it like this. But It's not recommended.</p>

<pre><code>    def __init__(self, name, email, password, *args, **kwargs):
        super(models.Model, self).__init__(*args, **kwargs)
        self.name = name
        self.email = email
        # or whatever you want
</code></pre>

<p>From Django docs</p>

<blockquote>
  <p>You may be tempted to customize the model by overriding the <strong>init</strong>
  method. If you do so, however, take care not to change the calling
  signature as any change may prevent the model instance from being
  saved.</p>
</blockquote>

<p>If you want add fields or do something else, trying to add a create method in your models</p>

<pre><code>from django.db import models

class Book(models.Model):
    title = models.CharField(max_length=100)

    @classmethod
    def create(cls, title):
        book = cls(title=title)
        # do something with the book
        return book

book = Book.create("Pride and Prejudice")
</code></pre>

python django