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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:18:43+00:00 2026-06-05T04:18:43+00:00

I’d really appreciate some guidance on how to construct the following models. I want

  • 0

I’d really appreciate some guidance on how to construct the following models. I want to make sure I’m doing this in the ideal way.

I want to keep track of some info about employees at my work. Basically, past Education and past Work Experience

So here’s the relations I can think of

  • Education
    • An employee could been to several school and each school can have many students (m2m)
    • Students attend a school for a period of time
    • a student can have multiple degrees form the same school and that school offers multiple degrees (m2m)
  • Work (almost the same as education)
    • m2m relation with employees and companies
    • employees work at a company to a set time
    • employes could have several jobs at one company (m2m)

Following basically what’s above, here’s the code I’ve worked out:

#make a list of numbers in a tuple
START_DATE_CHOICES = dict((str(x),str(x)) for x in range(date.today().year-30,date.today().year+1))
END_DATE_CHOICES = START_DATE_CHOICES
START_DATE_CHOICES = START_DATE_CHOICES.items()
START_DATE_CHOICES.sort()
START_DATE_CHOICES.reverse()
START_DATE_CHOICES = tuple(START_DATE_CHOICES)

END_DATE_CHOICES['current'] = 'current'
END_DATE_CHOICES = END_DATE_CHOICES.items()
END_DATE_CHOICES.sort()
END_DATE_CHOICES.reverse()
END_DATE_CHOICES = tuple(END_DATE_CHOICES)

#both schools and companies
class Institution(models.Model):
    name = models.CharField(max_length = 75)

class Education(models.Model):
    DEGREE_CHOICES = (
                      ('A.A.', 'Associate'),
                      ('Minor', 'Minor'),
                      ('B.A.', 'Bachelor of Arts'),
                      ('B.S.', 'Bachelor of Science'),
                      ('Masters', 'Masters'),
                      ('Ph. D.', 'Doctor of Philosophy'),
                      )
    school = models.ManyToManyField(Institution, through='Dates')
    degree = models.CharField(max_length = 5, choices = DEGREE_CHOICES, null = True)
    subject = models.CharField(max_length = 20, null = True)

class Work(models.Model):
    company = models.ManyToManyField(Institution, through='Dates')
    position = models.CharField(max_length = 50, null = True)
    jobDescription = models.TextField(null = True)

class Dates(models.Model):
    education = models.ForeignKey(Education, null = True)
    work = models.ForeignKey(Work, null = True)
    institution = models.ForeignKey(Institution)

    start = models.CharField(max_length = 4, choices = START_DATE_CHOICES)
    end = models.CharField(max_length = 7, choices = END_DATE_CHOICES)


class Person(models.Model):
    ....
    school = models.ManyToManyField(Institution, blank=True)
    education = models.ManyToManyField(Education, blank = True)
    company = models.ManyToManyField(Institution, blank = True, related_name="%(app_label)s_%(class)s_related")
    work = models.ManyToManyField(Work, blank=True)
    ....

So my question is: Is this an acceptable way of doing it? I’m a newbie and I’m not sure if I’m just abusing relationships

also, I’m sure there’s a easier way to do the whole start/end date thing… wasn’t able to figure it out though

Any pointers would be greatly appreciated, Thank you!

  • 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-06-05T04:18:44+00:00Added an answer on June 5, 2026 at 4:18 am

    For many to many fields you should use the plural form. for Person that would be educations and jobs for instance.

    Also it is convention to write job_description instead of jobDescription in model fields.

    In Person the fields school and company are redundant because that information is accessible through educations (currently education) and jobs (currently work) respectively.

    I think you don’t need the many to many field company in Work. A simple ForeignKey should suffice. I think you only have a specific job at ONE company for a given time. You can have mutliple jobs at the same time at multiple companies but still every job is at a single employer. Or am I wrong?

    The same goes for Education. You only have a degree in a specific subject from one school even if you went to several schools in the course of this education. Or do you want to model that situation that accurately?

    The naming of all dates is a bit misleading since they all are acually years. You also could use NULL in the end year as 'current' and use PositiveIntegerFields.

    Now I would have this code:

    #both schools and companies
    class Institution(models.Model):
        name = models.CharField(max_length = 75)
    
    class Education(models.Model):
        DEGREE_CHOICES = (
                          ('A.A.', 'Associate'),
                          ('Minor', 'Minor'),
                          ('B.A.', 'Bachelor of Arts'),
                          ('B.S.', 'Bachelor of Science'),
                          ('Masters', 'Masters'),
                          ('Ph. D.', 'Doctor of Philosophy'),
                          )
        school = models.ForeignKey(Institution)
        degree = models.CharField(max_length = 5, choices = DEGREE_CHOICES, null = True)
        subject = models.CharField(max_length = 20, null = True)
        start_year = models.PositiveIntegerField()
        end_year = models.PositiveIntegerField(null=True)
    
    class Job(models.Model):
        company = models.ForeignKey(Institution)
        position = models.CharField(max_length = 50, null = True)
        job_description = models.TextField(null = True)
        start_year = models.PositiveIntegerField()
        end_year = models.PositiveIntegerField(null=True)
    
    
    class Person(models.Model):
        ....
        educations = models.ManyToManyField(Education, blank = True)
        jobs = models.ManyToManyField(Work, blank=True)
        ....
    

    Of course if you want to have choices for the years you can have them

    YEAR_CHOICES = ((year, str(year)) for year in range(...))
    

    Alternatively you could write a custom validator for your year fields.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.