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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:43:00+00:00 2026-05-31T16:43:00+00:00

im having a two models one is companyusers and the other is qualification and

  • 0

im having a two models one is companyusers and the other is qualification
and one user has many qualifications
now i need to enter qualifications while creating the user in admin how do i do that?

i have tried to keep many to many field in the users model but in vain…
the qualifications that are related to other user is populating in the fields where as i need to create new qualification for the new user.

code follows..

class Qualification(models.Model):
    qualification = models.CharField(max_length=250)
    max_marks = models.IntegerField(max_length=50)
    marks_obtained = models.IntegerField(max_length=50)
    qualifying_year = models.DateField(auto_now=False, null=True)

class CompanyUser(User):
    date_of_birth = models.DateField(auto_now=False, null=True)
    position = models.CharField(max_length=100)
    qualifications = models.ManyToManyField(Qualification)

here is the company user details..

{"username":"steve","position":"Senior Engineer", "date_of_birth": "1986-05-14"}

{"qualification":"secondary school", "max_marks":"1000", "marks_obtained":"850", "qualifying_year":"1990"}

{"qualification":"undergraduation", "max_marks":"750", "marks_obtained":"680", "qualifying_year":"1992"}

{"qualification":"postgraduation", "max_marks":"1500", "marks_obtained":"1280", "qualifying_year":"1997"}

  • 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-31T16:43:01+00:00Added an answer on May 31, 2026 at 4:43 pm

    The One-To-Many relation you are looking for doesn’t exist in Django. It’s not needed, since you can do it the other way round: With a ForeignKey relation from the qualification to the user. According to your example, you would define the models as follows:

    class Qualification(models.Model):
        qualification = models.CharField(max_length=250)
        max_marks = models.IntegerField(max_length=50)
        marks_obtained = models.IntegerField(max_length=50)
        qualifying_year = models.DateField(auto_now=False, null=True)
        user = models.ForeignKey('CompanyUser', related_name='qualifications')
    
    class CompanyUser(User):
        date_of_birth = models.DateField(auto_now=False, null=True)
        position = models.CharField(max_length=100)
    

    So, there is no relation specified from CompanyUser to Qualification but you have a ForeignKey relation from Qualification to CompanyUser (i.e. each qualification belongs to one user, but multiple qualifications can belong to the same user). Django automatically maintains the backwards relation from CompanyUser to Qualification, which is the One-To-Many relation you are looking for. By the option related_name of the ForeignKey you can specify a meaningful name for the backwards relation (in this case ‘qualifications’). You can now simply access the Qualifications on a CompanyUser object with the attribute user.qualifications.

    In the admin you would first create a new CompanyUser and then an arbitrary number of Qualifications which you assign to this user via the ForeignKey.

    Be sure to read about that stuff in the Django docs section about Model relationships.

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

Sidebar

Related Questions

How do I go about having two view models communicate with one another using
I'm having two models, the first one ( model_1 ) accepts nested attributes for
The geonames database has two models that refer to each other. In a postgres
My Rails 3.1 app has two user models: User and Admin. I'm using Devise.
I need to ask the user for two security questions and their corresponding answers.
I have a layout which it has two partial views, one for LogIn and
I'm having trouble with my HABTM relationship in CakePHP. I have two models like
I'm having trouble using db.ReferenceProperty with PolyModel in GAE. If I have two models
Having a rfq model in the app. There are two fields. One is need_report
I am using MVC-View Model, EF Model first I am having problems with two

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.