Two separate Django apps require the same models

If I have two apps that would share similar models e.g. a job board project with 2 apps - candidates and recruiters that have models - Skills and categories.

Since candidates would need to state their skills and experience category to get tailored jobs and recruiters would need to state the skills and category they want from a candidate when posting a job.

Would it be better if I create a utils folder with the skills and category model or should I create a skills and category model in the Candidates app and import the models into the Recruiters app?

What is the best practice for this?

Regarding your specific question, the appropriate solution is that the models belong in one app and would be referenced by the other.

However, the very fact that you’re facing this issue raises the more fundamental question of “Do you want to do this at all?”, and my answer to that would be a resounding “No.”

Personally, I don’t see where “Candidates” and “Recruiters” would be two separate apps. Superficially, I don’t see where I would reuse one of those without the other.

I’m of the mindset that you should only have one app in your project until either:

  • There is a specific and coherent set of functionality that can (will) be reused across multiple projects.
  • The project has gotten so large that there’s no reasonable way to manage it as a single app. (Our threshold is somewhere around 50 models)

My gut reaction is that neither of those conditions would be true, and so both of those would belong in a “Jobs” app.

2 Likes

Thanks, that makes sense.

Would follow your advice