[Answered ]-Django model structure – best practice

2👍

This is a perfect case where you need to use the Generic Relations.

Instead of storing the Foreign Key to each one of those, you store the content type id (that recognizes Strawberries from Apples) and the object ids. You can of-course, develop this with your own conventions using the relevant strings within the Location model, but all that hard work is done for you in the django’s built in Content Type Framework.

👤lprsd

Leave a comment