0

i want to change constraint that SmallPositiveIntegerField produces in Db during migration:

last_watched_episode smallint
        constraint archives_seasonmodel_last_watched_episode_check
            check (last_watched_episode >= 0),

I want to change check (last_watched_episode >= 0) to check (last_watched_episode >= 1). Do you know where is the source code of this field in Django, that is in charge for making constraints? I need it in order to create mixin for this field. Thank you.

Point is to have only one constraint >=1 . If i did it via META class constraint, i would have 2 separete constraints >=0 and >= 1, which is makes no sence.

Aleksei Khatkevich
  • 1,923
  • 2
  • 10
  • 27
  • Does this answer your question? [Django set range for integer model field as constraint](https://stackoverflow.com/a/61265698/6836173) – wfehr Apr 28 '20 at 11:58
  • @wfehr No, as in this instance i would have to make another one constraint. so that i will have >=1 and >= 0 constraints simultaniously. what i want is to adjust default field constraint in order to create only one constraint in DB. Default is >=0. I want >= 1. It should be somewhere in source code. – Aleksei Khatkevich Apr 28 '20 at 12:04

0 Answers0