# Should literal db\_default values skip model validation?

**URL:** <https://forum.djangoproject.com/t/should-literal-db-default-values-skip-model-validation/45322>\
**Category:** ORM\
**Created:** [June 18, 2026, 5:07pm UTC](https://forum.djangoproject.com/t/should-literal-db-default-values-skip-model-validation/45322 "2026-06-18T17:07:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobtylerwalls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jacobtylerwalls/32/30603_2.png) [@jacobtylerwalls](https://forum.djangoproject.com/u/jacobtylerwalls)\
**Post date:** [June 18, 2026, 5:07pm UTC](https://forum.djangoproject.com/t/should-literal-db-default-values-skip-model-validation/45322/1 "2026-06-18T17:07:34Z")

</div>

We skipped model validation of `db_default` values to fix a crash in 5.0.4 ([PR](https://github.com/django/django/pull/17939)).

For generated values, that makes sense, and aligns with `GeneratedField`.

But for literal values, I find that surprising. Can’t we resolve the `db_default` expression to find out if it’s a literal value, and validate that?

Skipping model validation like this is, I think, unexpected – it’s not difficult for me to imagine db\_defaults and validation requirements either getting out of sync or being intentionally different (Django-writes being subject to stricter requirements than direct-writes):

```auto
from django.core import validators
from django.db import models

class Article(models.Model):
    slug = models.SlugField(db_default="not*sluggable")

    def __str__ (self):
        return self.slug

def run():
    instance = Article()
    instance.full_clean() # succeeds
    instance.save()
    print(f'Created: {instance}')
    # instance.full_clean() # fails

```

Direct validator usage also doesn’t work:

```auto
def run():
    instance = Article()
    instance._meta.get_field("slug").run_validators(instance.slug)

```

```auto
  File "/usr/local/lib/python3.12/site-packages/django/core/validators.py", line 503, in clean
    return len(x)
           ^^^^^^
TypeError: object of type 'DatabaseDefault' has no len()

```

---

<div class="post-metadata">

**Author:** ![jacobtylerwalls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jacobtylerwalls/32/30603_2.png) [@jacobtylerwalls](https://forum.djangoproject.com/u/jacobtylerwalls)\
**Post date:** [June 18, 2026, 9:23pm UTC](https://forum.djangoproject.com/t/should-literal-db-default-values-skip-model-validation/45322/2 "2026-06-18T21:23:09Z")

</div>

Just noticed that @shangxiao came to a similar conclusion [here](https://forum.djangoproject.com/t/proposal-to-have-db-default-considered-in-model-forms/33358/6) that we should unwrap literal values and validate them for _form_ fields, which I acknowledge is slightly different.
