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

  • Home
  • SEARCH
  • 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 6109757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:26:24+00:00 2026-05-23T14:26:24+00:00

some body please explain me the following i have two classes Userprofile and Staff.staff

  • 0

some body please explain me the following i have two classes Userprofile and Staff.staff inherits userprofile

My Question is that if any entry has to be made to a staff table .1.It would be mandatory to fill out the details of user profile right?

Please explain this inheritence.Thanks

  class Profile(models.Model):
     user = models.ForeignKey(User, unique=True)
     created_date = models.DateTimeField(auto_now_add=True)
     emp_first_name = models.CharField(max_length=255)
     emp_last_name = models.CharField(max_length=255)
     gender = models.CharField(max_length=2, choices = GENDER_CHOICES, null=False)
     date_of_birth = models.DateField(blank=True,null=True)
     address1 = models.CharField(max_length=255)
     city = models.CharField(max_length=48)
     state = models.CharField(max_length=48)
     country = models.CharField(max_length=48)
     email_id = models.EmailField(blank=True)


  class Staff(UserProfile):
     role = models.ManyToManyField(Role)
     designation = models.CharField(max_length=48, blank=True, null=True)
     education = models.CharField(max_length=255, blank=True, null=True)
  • 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-23T14:26:24+00:00Added an answer on May 23, 2026 at 2:26 pm

    If you take a look at https://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance you’ll see that automatic One-to-One mappings are created. Therefore, an entry for UserProfile is saved, and an entry for Staff is saved with a OneToOne field that points to the UserProfile entry.

    However, if you want Staff to just inherit all the fields, I’d recommend setting abstract = True in your UserProfile. This means that Staff inherits all those fields, but you can never create a UserProfile by itself (as described at
    https://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base-classes )

        class Meta:
            abstract = True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some question about the following switch in Linux Kernel, somebody can explain
could somebody please explain why this happens? I have written the following: 1) a
Possible Duplicate: What is a singleton in C#? could some body please explain me
Could somebody please explain or link to a resource that will tell me why
Can somebody explain the following code please? #if 1 // loop type #define FOR_IS_FASTER
I have the following code: http://jsfiddle.net/fCWJ5/1/ , and following doubts regarding the viewbox. body{margin:0;}
Please explain how the following snippet of code in C is a valid one
can somebody please explain what is the difference between the following mechanisms of passing
I am learning SQL and have some tables much like the following: Person (id*,
Can somebody please explain this to me: I have a label and I want

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.