hi,

Besides the solution provided by @nm,  maybe you can do it by using
database trigger ...

On Tue, Oct 22, 2019 at 2:05 AM Eileen Bauer <[email protected]> wrote:

> Hi,
> i have the following items in my model:
>     mother_alive = models.IntegerField(choices=YES_NO_CHOICES, blank=True,
> null=True, default=1)
>     father_alive = models.IntegerField(choices=YES_NO_CHOICES, blank=True,
> null=True, default=1)
>
> and I'd like to set up a generated field for them so I'd be able to detect
> whether the child is an orphan or not. In MySQL i believe it'd look like
> this:
>     orphan varchar(101) GENERATED ALWAYS AS (mother_alive+father_alive)
> VIRTUAL,
>
> I don't know how to change my model to do that...
>
> Any help?
>
> -Eileen
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/32b1c56f-f52d-4b63-bd93-db25cc1e89a6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/32b1c56f-f52d-4b63-bd93-db25cc1e89a6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABexzmiDjxRCBJR%2B-0o3OavfFMASL%2BtSpSWmi66nxbrp8nz9uA%40mail.gmail.com.

Reply via email to