title: Want to display the latest note entry only in Django
body: <p>I have another Django form that stores notes and again it has the user, client and datetime stored automatically. What I want to do this time is create some note form that allows you to add a note for a particular client, and every time you add a note it displays the <strong>latest result and only</strong> the latest result in the <code>client_details.html</code>template. So every time add a new note it will keep on replacing the existing note. How can I achieve this? </p>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class NoteForm(forms.ModelForm):
      class Meta:
          model = models.Note
          exclude = ('client','user','datetime')
  </code></pre>
  
  <p><strong>Views.py</strong></p>
  
  <pre><code>@login_required
  def get_client(request, client_id = 0):
      client = None
      try:
          client = models.Client.objects.get(pk = client_id)
          notes = client.note_set.all()
          comments = client.comment_set.order_by('-datetime')
      except:
          pass
      return render_to_response('client_details.html', {'client':client, 'notes':notes, 'comments':comments}, context_instance = RequestContext(request))
  
  @login_required
      def add_notes(request, client_id = 0):
          client = None
          contact = None
          try:
              client = models.Client.objects.get(pk = client_id)
          except:
              return HttpResponseNotFound()
  
          if request.method == 'POST':
              form = forms.NoteForm(request.POST)
              if form.is_valid():
                  note = form.save(commit=False)
                  note.user = request.user
                  note.client = client
                  note.save(True)
                  request.user.message_set.create(message = "Note is successfully added.")
                  return HttpResponse("&lt;script language=\"javascript\" type=\"text/javascript\"&gt;window.opener.location = window.opener.location; window.close();&lt;/script&gt;")
          else:
              form = forms.NoteForm()
          return render_to_response('note_form.html', {'form':form, 'client':client}, context_instance = RequestContext(request))
  </code></pre>