title: How to resolve Django IntegrityError NOT NULL Constraint Field?
body: <p>I'm building an online judge in which I have a Question model and an Answer model.</p>
  <p><code>models.py</code></p>
  <pre><code>from django.db import models
  from django.core.validators import FileExtensionValidator
  from django.urls import reverse
  
  class Question(models.Model):
      title = models.CharField(max_length=100)
      content = models.TextField()
      solution = models.FileField(
      validators=[FileExtensionValidator(allowed_extensions=['txt'])], upload_to= 'media')
  
      def __str__(self):
          return self.title
  
      def get_absolute_url(self):
          return reverse('coder:detail', kwargs={'pk': self.pk})
  
  class Answer(models.Model):
      question = models.ForeignKey(Question, on_delete=models.CASCADE)
      result = models.CharField(max_length=100,default = 'answer', null = True, blank = True)
      # result = models.FileField( null= True, blank=True, default = 'media/media/output.txt',
      # validators=[FileExtensionValidator(allowed_extensions=['txt'])], upload_to= 'media')
  
      def __str__(self):
          return f'{self.question.title} Answer'
      def get_absolute_url(self):
          return reverse('coder:detail', kwargs={'pk': self.pk})
  </code></pre>
  <p><code>views.py</code></p>
  <pre><code>from django.shortcuts import get_object_or_404, render
  from django.urls import reverse_lazy
  from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
  from django.views.generic import ListView, DetailView, CreateView, UpdateView, RedirectView
  from django.db.models import Q
  from .models import Question, Answer
  
  
  class CoderListView(ListView):
      model = Question
      template_name = &quot;coder/coder_list.html&quot;
      context_object_name = 'question'
  
  
  class CoderDetailView(DetailView):
      model = Question
      template_name = &quot;coder/coder_detail.html&quot;
  
  
  class CoderCreateView(CreateView):
      model = Answer
      fields = ['result']
      context_object_name = 'answer'
      success_url = reverse_lazy('coder:list')
      template_name = &quot;coder/coder_form.html&quot;
  
      def form_valid(self, form):
          return super().form_valid(form)
  </code></pre>
  <p>What exactly am I doing wrong here?</p>
  <p>I was trying out FileField earlier but when I kept getting an error, I tried CharField after flushing the database to debug further but I kept getting this error:</p>
  <p><a href="https://i.stack.imgur.com/Kktk3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kktk3.png" alt="image" /></a></p>
  <p>And yes, I did try out setting null, blank, and default values appropriately but still no luck. Maybe something to do with a <code>signals.py</code> file? Or maybe I'm implementing the Foreign key wrong, whatever it is that I'm doing wrong I'm unable to point out at the moment. Help with that would be appreciated.</p>
  <p>This page is using CoderCreateView.</p>