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 6079287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:55:46+00:00 2026-05-23T10:55:46+00:00

Hello I want to make a change to my models.py. I have two tables.

  • 0

Hello I want to make a change to my models.py.

I have two tables. Client and Note. What I want to do is have a note field in the clients table which should have some one-one relationship with the Note table.

However,the note will have to store some user, client and a date time. So I need another table to do this. But I want some one-one relationship with client and note.

A client should only be able to store in one note. A note has a user, datetime, a note text field and client (If I have a note field in the Client’s table, I don’t think I need this entry).

models.py

   class Client(models.Model):
        name = models.CharField(max_length = 40)
        telephone = models.CharField(max_length = 20)
        website = models.URLField(verify_exists = False)
        fax = models.CharField(max_length = 20)
        email = models.EmailField()
        is_active = models.BooleanField()
        def __unicode__(self):
            return self.name

    class Note(models.Model):
        client = models.ForeignKey(Client)
        datetime = models.DateTimeField(default=datetime.now)
        user  = models.ForeignKey(User)
        note = models.TextField()

        def __unicode__(self):
            return unicode(self.user)
  • 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-23T10:55:47+00:00Added an answer on May 23, 2026 at 10:55 am

    Justinas is right. You should add a note field to your Client model, which makes the FK on your Note model obsolete. Something like this should get you started:

    class Note(models.Model):
        datetime = models.DateTimeField(default=datetime.now)
        user  = models.ForeignKey(User)
        note = models.TextField()
    
        def __unicode__(self):
            return unicode(self.user)
    
    class Client(models.Model):
        name = models.CharField(max_length = 40)
        telephone = models.CharField(max_length = 20)
        website = models.URLField(verify_exists = False)
        fax = models.CharField(max_length = 20)
        email = models.EmailField()
        is_active = models.BooleanField()
        note = models.OneToOneField(Note)
    
        def __unicode__(self):
            return self.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a word press options page and I want to make it
Hello i want to make animation of a frame change. But i don't find
Hello I have two text inputs which get their values from a datepicker. What
Hello I want to make an application which uses Multi-touch support. for multitouch i
Hallo I want to make an file upload. The script should take the image,
Hello I want to read output of command which gives progress bar like output
Hello I want write my own desktop sharing application in Java. The application should
I have: %{ lorem ipsum dolor sit %{hello world}% amet}% I want: hello world
Got a problem about server-client: When server is running, if I want to make
i want to make function to change letters to special letters like i made

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.