#34403 closed Uncategorized (duplicate)
max_length argument for the CharField is not respected through shell
Description ¶
In this example,
class country(models.Model):
name = models.CharField(max_length=80)
code = models.CharField(max_length=3)
The code field has a maximum length of 3, but through the shell, the length seems to be exceeded without throwing a validation error. But from the Django Admin portal, the character length appears to work as expected.
I've taken screenshots to show the existence of the bug.
Change History (4)
by , 2 years ago
Attachment: | Screen Shot 2023-03-10 at 2.12.48 PM.png added |
---|
comment:1 by , 2 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Model.save()
doesn't call model validation, see #34061.
comment:3 by , 2 years ago
Replying to Ittach1:
It is the same behaviour for .create (..)
Yes, you have to call full_clean()
manually.
The screenshot displays how the max_length is exceeded, but a validation error is not raised.