[Django] #34403: max_length argument for the CharField is not respected through shell

10 views
Skip to first unread message

Django

unread,
Mar 10, 2023, 3:14:05 PM3/10/23
to django-...@googlegroups.com
#34403: max_length argument for the CharField is not respected through shell
-----------------------------------------+------------------------
Reporter: ittach1 | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34403>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 10, 2023, 3:15:14 PM3/10/23
to django-...@googlegroups.com
#34403: max_length argument for the CharField is not respected through shell
-------------------------------+--------------------------------------

Reporter: ittach1 | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by ittach1):

* Attachment "Screen Shot 2023-03-10 at 2.12.48 PM.png" added.

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

Django

unread,
Mar 10, 2023, 4:17:09 PM3/10/23
to django-...@googlegroups.com
#34403: max_length argument for the CharField is not respected through shell
-------------------------------+--------------------------------------
Reporter: Ittach1 | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/34403#comment:1>

Django

unread,
Mar 10, 2023, 4:22:10 PM3/10/23
to django-...@googlegroups.com
#34403: max_length argument for the CharField is not respected through shell
-------------------------------+--------------------------------------
Reporter: Ittach1 | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Ittach1):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/34403#comment:2>

Django

unread,
Mar 10, 2023, 4:45:29 PM3/10/23
to django-...@googlegroups.com
#34403: max_length argument for the CharField is not respected through shell
-------------------------------+--------------------------------------
Reporter: Ittach1 | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:2 Ittach1]:


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

Yes, you have to call `full_clean()` manually.

--
Ticket URL: <https://code.djangoproject.com/ticket/34403#comment:3>

Reply all
Reply to author
Forward
0 new messages