Closed sveetch closed 3 years ago
Also i thought of a case with the publish start which is a datetime. But urls will only use the date part, not the time. This is buggy since two articles with the same slug can have the same date but a different time but this will result to an error when trying to resolve their object from url arguments.
Django did this at programming level: https://docs.djangoproject.com/en/3.1/ref/models/fields/#unique-for-date
I don't have many idea for correct implementation of custom constraint management and not enough time to think about it. Also the db level implementation is still a nice way to do it so we will keep it.
Finally, i just refactored modelization so we use a simple date for publication start to avoid problem with unique constraint on date+lang+slug.
Currently An Article can't have the same combination of slug, publish date and language, this is enforced at db level with a model constraint. This has been made because we plan to have Article detail url on this combination so user can create many Article with either the same slug or same date.
But if a developer want to change urls to display only the slug and not the date, the slug should be unique.
It could be possible to manage constraint in some validators which could be customized, but it may decrease performance against the db level way.. ?