Cross link tables in Django

G’day All,

I am transitioning from building a solution in Access to trying to replicate it in Django. I have a data model where there is a table that has companies and another table that has capabilities and I currently use a third table to link which companies have what capabilities.

In Django, the issue I have struck is that this is a table with just two foreign keys, so the str function is not happy. Two questions:

  1. Am I using the right approach
  2. If so, how should it be configure in the model to work best.

Thanks

This is what’s known as a Many-to-Many relationship between the companies and capabilities table.

Yes it’s the right approach, see the documentation referenced above.

If you’re having a specific problem with your models, it would be helpful for you to include your models in your post so that people can see what you’re trying to do.

Ken

Thanks for responding Ken.

It dawned on me after I posted the question and I have it sorted out now.