#34403 closed Uncategorized (duplicate)
max_length argument for the CharField is not respected through shell
Reported by: | Ittach1 | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 4.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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.
Attachments (1)
Change History (4)
by , 21 months ago
Attachment: | Screen Shot 2023-03-10 at 2.12.48 PM.png added |
---|
comment:1 by , 21 months ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Model.save()
doesn't call model validation, see #34061.
comment:3 by , 21 months 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.