title: How to auto initialize fields in a Django model?
body: <p>I have the following model in Django and basically I need to to auto initialize 3 out of 5 fields once the user has inserted some data, i.e.,</p>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>class Assignment(models.Model):
      assignment       = models.CharField(max_length=60)
      comments         = models.CharField(max_length=60)
      starting_date    = models.DateField()
      points           = models.IntegerField()
      STATUS = (('A', 'Active'), ('C', 'Cancelled'), ('D', 'Done'))
      status           = models.CharField(max_length=1, choices=STATUS)
  </code></pre>
  
  <p><strong>Forms.py</strong></p>
  
  <pre><code>from django import forms
  from .models import Task
  
  class TaskForm(forms.ModelForm):
      class Meta:
          model = Task
          starting_date = datetime.now()
          fields = ['task_description', 'task_comments', 'starting_date', 'priority', 'points']
  </code></pre>
  
  <p><strong>Input form</strong></p>
  
  <pre><code>&lt;!-- Input form to request to values--&gt;
  &lt;div class="panel-heading"&gt;Add a new assignment &lt;/div&gt;
    &lt;form id ="insert_new_assign" class="form-horizontal" method="POST"&gt;
      {% csrf_token %}
      &lt;div class="panel-body"&gt;
        &lt;div class="input-group"&gt;
          &lt;input class="form-control" name="insert_new_assign_field" type="text" placeholder="Insert your new assignment here" /&gt;
          &lt;input class="form-control" name="insert_new_comment_field" type="text" placeholder="Any comment you want to add?" /&gt;
          &lt;button class="btn btn-primary" type="submit"&gt;Add&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><a href="https://jsfiddle.net/rwkx6L0n/" rel="nofollow noreferrer">See the JS fiddle for quick reference</a></p>
  
  <p>Basically when the user enters a new assignment and comment, <strong>I want Django to save these two fields and auto initialize the other fields with the current time, 0 points and A status</strong>. Whenever I try to to save a new record, I get the error <code>The view engine.views.home didn't return an HttpResponse object</code> which is normal because Django expects from the user to complete all the fields and not only two. </p>
  
  <p><strong>Previous research</strong></p>
  
  <p>Based on some research, I found out that only <a href="https://teamtreehouse.com/community/how-to-autofill-a-field-in-the-database" rel="nofollow noreferrer">one field can be completed in a Django model</a> - the id - but at the same time they mention the <code>Custom Managers</code> which  are classes that can address the problem I have, however, <a href="https://docs.djangoproject.com/en/2.1/topics/db/managers/" rel="nofollow noreferrer">the examples they provide do not fit for my current situation</a>. </p>
  
  <p><strong>My main question is:</strong></p>
  
  <p>How can I indicate in Django to save the two fields and auto initialize the other fields with the current date and time, 0 points and A status?</p>
  
  <p>Any help in this questions will be greatly appreciated, feel free to improve this question as well.</p>