title: In Django, how to add username to a Model automatically, when the Form is submitted by a logged in user
body: <p>In my Django app, I have defined a Many-to-one relationship using ForeignKey. <strong>Now what I want is that when a logged-in user submits the <code>ListForm</code> then his <code>username</code> should automatically add to the <code>owner</code> field of the <code>ListModel</code>.</strong> Currently when a user submits the form, <code>None</code> is being shown in the owner field, how can I add the username to the database along with the form?</p>
  <p><strong>my models.py:</strong></p>
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  
  class ListModel(models.Model):
      owner = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
      task = models.CharField(max_length=255)
      completed = models.BooleanField(default=False)
  </code></pre>
  <p><strong>my forms.py:</strong></p>
  <pre><code>from django.forms import ModelForm
  from .models import ListModel
  from django import forms
  
  
  class ListForm(ModelForm):
      class Meta:
          model = ListModel
          fields = ['owner','task', 'completed']
  </code></pre>