Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6068753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:44:56+00:00 2026-05-23T09:44:56+00:00

I have another Django form that stores notes and again it has the user,

  • 0

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 latest result and only the latest result in the client_details.htmltemplate. So every time add a new note it will keep on replacing the existing note. How can I achieve this?

forms.py

class NoteForm(forms.ModelForm):
    class Meta:
        model = models.Note
        exclude = ('client','user','datetime')

Views.py

@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("<script language=\"javascript\" type=\"text/javascript\">window.opener.location = window.opener.location; window.close();</script>")
        else:
            form = forms.NoteForm()
        return render_to_response('note_form.html', {'form':form, 'client':client}, context_instance = RequestContext(request))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:44:56+00:00Added an answer on May 23, 2026 at 9:44 am

    add to your view:

    try:
        last_note = client.note_set.latest("datetime")
    except DoesNotExist:
        last_note = None
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form (Form1) that has a NotifyIcon on it. I have another
I have a table (user) that contains user information. I have another table (userview)
I've built a Django form that submits to a page on another domain (that
I have a registration form that when the user enters in valid registration data
I have created a django app. It has got a user login/registration on the
A little background, I have a client that has a legacy php site that
I have another programmer who I'm trying to explain why it is that a
I am new to Django, and want to do the following I have a
I am trying to get a login form I have in django to only
I'm new to Django, trying to process some forms. I have this form for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.