So this happened not to be supported in Django 3.0 either.
But https://github.com/django/django/pull/12067 should add support for it.
Le jeudi 14 novembre 2019 15:50:34 UTC-5, Simon Charette a écrit :
>
> For the record I haven' tested the above myself.
>
> It might only work on Django 3.0+ and
For the record I haven' tested the above myself.
It might only work on Django 3.0+ and require you to pass
`output_field=BooleanField()` to Func.
Le jeudi 14 novembre 2019 09:46:48 UTC-5, Simon Charette a écrit :
>
> Hello there,
>
> I guess your example is not the best since this check could
Hello there,
I guess your example is not the best since this check could be defined on
Author.Meta.constraints
directly but if you wanted to define such a check on Book anyway you'll
have to define a function
and refer to it in the check constraint using Func.
Using RunSQL in your migrations
Hello,
Let say I want to enforce a database constraint saying a "book's author age
is over 18".
As you may guess, books and authors are each described with a Model
subclass with a foreign key (in this example each book is written by a
single author) linking both.
class Author(models.Model):
4 matches
Mail list logo