2๐
โ
I recently stumbled upon this awesome feature of Django and reading the docs page made it all clear.
To expand a little bit, generic relations is when you want a Model to be able to be associated to more than 1 other Model. In the example above, because it is using a GenericKey, a Comment can belong to multiple models (like a Question or an Answer, etc.)
In my particular use sample, I had an AddressProfile model and I wanted both the User model and the Company model to be able to have an AddressProfile. I initially simply had two ForeignKeys in the AddressProfile with null=True so I could specify whichever relation it was, but the GenericKey functionality made it much cleaner for me.
๐คPaolo Bergantino
Source:stackexchange.com