title: Django SQLite UPDATE
body: <p>I am developing a webapp using django. Generally, I want to keep track of how much time a user has devoted to a project. So when the user starts working, I am registering a "Change" object in the database with the user, the project, and what time he start working. Now, how can I get the same "Change" object to a different view to log the end time? In my best attempt I got an "IntegrityError NOT NULL constraint failed". Here is the code:</p>
  
  <p><b>views.py</b></p>
  
  <pre><code>@login_required
  def main(request):
      context = RequestContext(request)
      user=request.user
      if request.method=='POST':
          projectid=request.POST['project']
          project = Project.objects.get(pk=int(projectid))
          if project:
              change=Change(user=user, project=project,starttime=datetime.now())
              change.save()
              #return HttpResponse("I \'ve already start counting... You \'ve wasted 5 seconds already. Just joking. I don\'t know how to count...")
              return render_to_response('ProjectLogging/timer.html', {'change':change}, context_instance=RequestContext(request))
          else:
              HttpResponse("Choose a valid project!")
      else:
          HttpResponse("Choose a POST method (???????)")
  
  @login_required
  def timer(request, change):
      user=request.user
      # schange=request.change
      if request.method=='POST':
          change=Change(endtime=datetime.now())
          change.save()
          return render_to_response('ProjectLogging/main.html',{'user':user, 'project_list':Project.objects.all()}, context_instance=RequestContext(request))
      else:
          return HttpResponse("Something went wrong with timer view.")
  </code></pre>
  
  <p><b>urls.py</b></p>
  
  <pre><code>urlpatterns=patterns('ProjectLogging',
      url(r'^$', 'views.login', name="index"),
      url(r'^login/$', 'views.login', name="login"),
      url(r'^logout/$', 'views.logout', name="logout"),
      url(r'^main/$','views.main', name="main"),
      url(r'^timer/$', 'views.timer', {'change':'change'}),
  )
  </code></pre>
  
  <p>and the <b>Change</b> model</p>
  
  <pre><code>class Change(models.Model):
      user=models.ForeignKey(User)
      project=models.ForeignKey('Project')
      starttime=models.DateTimeField(null=True,blank=True)
      endtime=models.DateTimeField(null=True, blank=True)
      flagged=models.BooleanField(default=False, db_index=True)
  
      def __repr__(self):
          return ('Change in project %r from %r' % (self.project.title, self.user.username))
  
      def __unicode__(self):
          return ('%r in project: %r' % (self.user.get_full_name(), self.project.title))
  
      def user_changes(self, user):
          return self.filter(user==user)
  </code></pre>
  
  <p>Sorry for the primitive code. I m new to both Django and Python.</p>