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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:44:10+00:00 2026-06-13T00:44:10+00:00

Note: I’ve since asked this question again given the updates to Django’s user model

  • 0

Note: I’ve since asked this question again given the updates to Django’s user model since version 1.5.

I’m rebuilding and making improvements to an already existing Django site and moving it over from Webfaction to Heroku, and from Amazon’s SimpleDB to Heroku Postgres (though testing locally on Sqllite3 when developing). A lot of what I’m doing is moving over to use built-in Django functionality, like the Django admin, user authentication, etc.

Conceptually, the site has two kinds of users: Students and Businesses. The two types of users have completely different permissions and information stored about them. This is so much the case that in the original structure of the site, we set up the data model as follows:

Users
    ID (primary_key)
    Business_or_Student ('B' if business, 'S' if student)
    email (unique)
    password (hashed, obviously)
    ...

Students
    ID (Foreignkey on Users)
    <more information>
    ...

Businesses
    ID (Foreignkey on Users)
    <more information>
    ...

This worked pretty well for us, and we had the bare-bones user information in the Users table, and then any more detailed information in the Students and Businesses tables. Getting a user’s full profile required something along this pseudocode:

def get_user_profile(id):
    if Users(id=id).Business_or_Student = 'B':
        return Businesses(id=id)
    else:
        return Students(id=id)

In moving over, I’ve found that Django’s built-in User object has pretty limited functionality, and I’ve had to extend it with a UserProfile class I’ve created, and then had additional Student and Business tables. Given all of the patching I’m doing with this in the Django admin, and being relatively unfamiliar with Django models since I always did it differently, I’m not sure if this is the best way to go about it, or if I should just stick all of the information for businesses and students in the UserProfile table and just differentiate the two with different groups, or if there’s even some way to do this all in the built-in User object.

Since businesses and students also have different interfaces, I’m seriously considering setting up the two as different apps within my Django project, and so separating their views, models, etc. entirely. That would look something like:

MyProject/
    MyProject/ (project folder, Django 1.4)
    mainsite/
    students/
    businesses/

One of my biggest concerns is with the Django Admin. In extending User, I already had to add the following code:

class UserProfileInline(admin.StackedInline):
    model = UserProfile
    can_delete = False
    verbose_name_plural = 'profile'

class UserAdmin(UserAdmin):
    inlines = (UserProfileInline, )

However, I would like the information for the Business or Student aspects of the user to show up in the Django admin when that User is pulled up, but the ForeignKey part of the model is in the Student and Business model since every Student/Business has a User but every User has only one Student or one Business object connected with it. I’m not sure how to add a conditional Inline for the Admin.

Question: Given this structure and these concerns, what is the best way to set up this site, particularly the data model?

  • 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-13T00:44:11+00:00Added an answer on June 13, 2026 at 12:44 am

    This is not a complete solution, but it will give you an idea of where to start.

    • Create a UserProfile model in mainsite. This will hold any common attributes for both types of users. Relate it to the User model with a OneToOne(...) field.
    • Create two more models in each app, (student/business), Business and Student, which have OneToOne relationships each with UserProfile (or inherit from UserProfile). This will hold attributes specific to that type of users. Docs: Multitable inheritance / OneToOne Relationships
    • You may add a field in UserProfile to distinguish whether it is a business or student’s profile.

    Then, for content management:

    • Define the save() functions to automatically check for conflicts (e.g. There is an entry for both Business and Student associated with a UserProfile, or no entries).
    • Define the __unicode__() representations where necessary.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: This is an old question and the answers here no longer works (since
NOTE: This is an entire rewrite of the previous question. I have a model.
Note: Originally this question was asked for PostgreSQL, however, the answer applies to almost
Note: This might seem like a Super User question at first, but please read
Note, this is not a duplicate of .prop() vs .attr() ; that question refers
(Note: This is not a question about what is the best way with code
NOTE: This is a followup to my question here. I have a program that
Note: To answer this question, you shouldn't have to know anything about Selenium or
note: this question is related to PostGIS and Postgresql and is implemented with PHP
Note: This question is similar to How to prevent the copy of XML documentation

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.