Re: How to store a key to a something that can be either a person or an organization?

2017-10-23 Thread James Schneider
On Oct 21, 2017 2:06 AM, "Antonis Christofides" < anto...@djangodeployment.com> wrote: Hello James, You are right that the correct term in everyday language for the superclass of organization and person is "entity". However, I didn't want to name it "entity" in the code, because, really, "entity"

Re: How to store a key to a something that can be either a person or an organization?

2017-10-21 Thread Antonis Christofides
Hello James, You are right that the correct term in everyday language for the superclass of organization and person is "entity". However, I didn't want to name it "entity" in the code, because, really, "entity" is a different thing in programming, it's a term like "object". It would be very confus

Re: How to store a key to a something that can be either a person or an organization?

2017-10-21 Thread James Schneider
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. Seems silly to name a model as such given that it c

Re: How to store a key to a something that can be either a person or an organization?

2017-10-21 Thread James Schneider
On Oct 20, 2017 4:15 AM, "Jani Tiainen" wrote: Hi. I've resolved such a case with two nullable fkeys and a discriminator field to tell which one fkey is used. Another option that is slightly safer is to override the save() method to set the opposing FK to None every time the model is saved. Yo

RE: How to store a key to a something that can be either a person or an organization?

2017-10-20 Thread Matthew Pava
Behalf Of Jani Tiainen Sent: Friday, October 20, 2017 2:24 PM To: django-users@googlegroups.com Subject: Re: How to store a key to a something that can be either a person or an organization? I would be a bit cautious with generic foreignkeys since they don’t provide database integrity checks. IOW

Re: How to store a key to a something that can be either a person or an organization?

2017-10-20 Thread Jani Tiainen
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 wrote: > > You can use Generic Key: > https://docs.djangoproject.com/en/1.11/ref/contrib/contenttypes/ >

Re: How to store a key to a something that can be either a person or an organization?

2017-10-20 Thread Ruben Alves
You can use Generic Key: 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): > ...

Re: How to store a key to a something that can be either a person or an organization?

2017-10-20 Thread Jani Tiainen
Hi. I've resolved such a case with two nullable fkeys and a discriminator field to tell which one fkey is used. 20.10.2017 12.59 "Antonis Christofides" kirjoitti: Hello, Two real examples that I've faced: class MeteorologicalStation(models.Model): ... owner = models.Foreig

How to store a key to a something that can be either a person or an organization?

2017-10-20 Thread Antonis Christofides
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 c