Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#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)

Screen Shot 2023-03-10 at 2.12.48 PM.png (177.6 KB ) - added by Ittach1 21 months ago.
The screenshot displays how the max_length is exceeded, but a validation error is not raised.

Download all attachments as: .zip

Change History (4)

by Ittach1, 21 months ago

The screenshot displays how the max_length is exceeded, but a validation error is not raised.

comment:1 by Mariusz Felisiak, 21 months ago

Resolution: duplicate
Status: newclosed

Model.save() doesn't call model validation, see #34061.

comment:2 by Ittach1, 21 months ago

It is the same behaviour for .create (..)

in reply to:  2 comment:3 by Mariusz Felisiak, 21 months ago

Replying to Ittach1:

It is the same behaviour for .create (..)

Yes, you have to call full_clean() manually.

Note: See TracTickets for help on using tickets.
Back to Top