I would be a bit cautious with generic foreignkeys since they don’t provide database integrity checks.
IOW, you can break your data very easily. > On 20 Oct 2017, at 19.55, Ruben Alves <[email protected]> wrote: > > You can use Generic Key: > https://docs.djangoproject.com/en/1.11/ref/contrib/contenttypes/ > <https://docs.djangoproject.com/en/1.11/ref/contrib/contenttypes/> > > > > Em sexta-feira, 20 de outubro de 2017 07:59:35 UTC-2, Antonis Christofides > escreveu: > Hello, > > Two real examples that I've faced: > > class MeteorologicalStation(models.Model): > ... > owner = models.ForeignKey(to a person or organization) > > > class Document(models.Model): > ... > authors = models.ManyToManyKey(to persons or organizations) > > What I do is I create a superclass that I call Lentity (short for "legal > entity", despite the fact that it could refer to a group of people and is not > necessary legal) and the two subclasses Person and Organization, with > multi-table inheritance. > > But since I guess that this is a relatively common problem, I was wondering > about what other people are doing. > > Thanks! > > Antonis > > -- > Antonis Christofides > http://djangodeployment.com <http://djangodeployment.com/> > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/django-users > <https://groups.google.com/group/django-users>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/f1fcc861-b3f3-43dc-9bad-a2511de4da44%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/f1fcc861-b3f3-43dc-9bad-a2511de4da44%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/72D4C974-6300-4F06-8C80-C4E0EA9D398F%40gmail.com. For more options, visit https://groups.google.com/d/optout.

