title: Django Help: Resolving NOT NULL constraint failed error with CreateView
body: <p>I am new to stackoverflow, python and Django, have a question on the '(NOT NULL constraint failed: sixerrapp_gig.user_id)' error I am getting when i click submit on the form. </p>
  
  <p>Pretty sure it is because I have not assigned a user_id value from what I have found on StackOverflow thus far, but I am not sure how to do it using the django CreateView. </p>
  
  <p>The project exercise is based on a clone of fiverr.com.</p>
  
  <p>Please see code below:</p>
  
  <p>in models.py:</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  from django.utils import timezone
  from django.core.urlresolvers import reverse #for model forms
  
  class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      avatar = models.CharField(max_length=500)
      about = models.CharField(max_length=1000)
  
      def __str__(self):
          return self.user.username
  
  class Gig(models.Model):
      CATEGORY_CHOICES = (
          ("GD", "Graphics &amp; Design"),
          ("DM", "Digital &amp; Marketing"),
          ("VA", "Video &amp; Animation"),
          ("MA", "Music &amp; Audio"),
          ("PT", "Programming &amp; Tech")
      )
      title = models.CharField(max_length=500)
      category = models.CharField(max_length = 2, choices=CATEGORY_CHOICES)
      description = models.CharField(max_length=1000)
      price = models.IntegerField(default=6)
      photo = models.FileField(upload_to='gigs')
      status = models.BooleanField(default=True)
      user = models.ForeignKey(User)
      create_time = models.DateTimeField(default=timezone.now)
  
      def get_absolute_url(self):
          return reverse('my_gigs')
  
      def __str__(self):
          return self.title
  </code></pre>
  
  <p>views.py:</p>
  
  <pre><code>from django.shortcuts import render, redirect
  from django.contrib.auth.decorators import login_required
  from django.views import generic
  from django.views.generic.edit import CreateView, UpdateView, DeleteView
  from .models import Gig
  from .forms import GigForm
  
  class CreateGig(CreateView):
      model = Gig    
      fields = ['title','category','description','price','photo','status']
  </code></pre>
  
  <p>gig_form.html</p>
  
  <pre><code>{% extends 'base.html' %}
  {% load staticfiles %}
  
  {% block page %}
  
  &lt;form action="" method="post" enctype="multipart/form-data"&gt;
  {% csrf_token %}
  {% include 'sixerrapp/form-template.html' %}
  &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  
  {% endblock %}
  </code></pre>
  
  <p>What i think i need is for the user field to get a value automatically when the form is submitted. Not sure what I am missing in my code to do that.</p>
  
  <p>Thanks in advance for the help! </p>