[Answer]-Django- connecting models for newbie

1👍

This completely depends on the type of relationship you need.

  • If there is 1 job per user, then by all means put a field on Job or User that points to its target.
  • If there’s a many-job-to-single-user relationship, add a foreign key to the Job model.
  • If there’s a many job to many user relationship, add an m2m field on either.
  • If there’s a many user to single job relationship, put the foreignkey on your user model (each user has 1 job, max).

AUTH_PROFILE_MODULE ?

You would under most circumstances not want to point any FKs to this Profile table, because django works pretty tightly with the User model and you are more likely to have access to a list of Users than UserProfiles from which to query Jobs or whatever other relationship.

Leave a comment