[Django] #29647: "Please correct the error below." when saving edit model form with inline formset and space at the end of primary key value

9 views
Skip to first unread message

Django

unread,
Aug 7, 2018, 6:49:38 AM8/7/18
to django-...@googlegroups.com
#29647: "Please correct the error below." when saving edit model form with inline
formset and space at the end of primary key value
-----------------------------------------+------------------------
Reporter: uralov | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.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 |
-----------------------------------------+------------------------
I have an Attribute instance in DB with name 'Motor type ' (space in the
end). Also, I have AttributeValueInlineAdmin as inline for AttributeAdmin.
When I try to change field display_name for that instance in Django admin
I get an error "Please correct the error below." with no errors shown.

The reason for that error is the space at the end of the primary key.

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

Django

unread,
Aug 7, 2018, 6:54:20 AM8/7/18
to django-...@googlegroups.com
#29647: "Please correct the error below." when saving edit model form with inline
formset and space at the end of primary key value
-------------------------------+--------------------------------------

Reporter: uralov | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.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 uralov):

* Attachment "admin.py" added.

Models and admin classes

Django

unread,
Aug 7, 2018, 6:58:10 AM8/7/18
to django-...@googlegroups.com
#29647: "Please correct the error below." when saving edit model form with inline
formset and space at the end of primary key value
-------------------------------+--------------------------------------

Reporter: uralov | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.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 uralov):

* Attachment "admin_error.png" added.

Django

unread,
Aug 7, 2018, 8:22:17 AM8/7/18
to django-...@googlegroups.com
#29647: "Please correct the error below." when saving edit model form with inline
formset and space at the end of primary key value
-------------------------------+--------------------------------------

Reporter: uralov | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.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
-------------------------------+--------------------------------------

Comment (by Tim Graham):

I can't reproduce this given the models and admin you provided. Which
version of Django are you using? Starting
[https://docs.djangoproject.com/en/dev/releases/1.9/#miscellaneous in
Django 1.9]:
CharField now strips input of leading and trailing whitespace by default.
This can be disabled by setting the new strip argument to False.

The behavior I see when editing an `Attribute` whose `name` contains a
trailing space is that a new instance is created because primary keys
aren't editable as described in #2259.

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

Django

unread,
Aug 8, 2018, 2:23:05 AM8/8/18
to django-...@googlegroups.com
#29647: "Please correct the error below." when saving edit model form with inline
formset and space at the end of primary key value
-------------------------------+--------------------------------------
Reporter: Alex Uralov | Owner: nobody

Type: Bug | Status: new
Component: contrib.admin | Version: 2.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
-------------------------------+--------------------------------------

Comment (by Alex Uralov):

Replying to [comment:1 Tim Graham]:


> I can't reproduce this given the models and admin you provided. Which
version of Django are you using? Starting
[https://docs.djangoproject.com/en/dev/releases/1.9/#miscellaneous in
Django 1.9]:
> CharField now strips input of leading and trailing whitespace by
default. This can be disabled by setting the new strip argument to False.
>
> The behavior I see when editing an `Attribute` whose `name` contains a
trailing space is that a new instance is created because primary keys
aren't editable as described in #2259.

I use Django==2.0.8. Could you reproduce this by steps:
1) Create a new Attribute item without spaces. For example 'test'
2) Change the name (primary key) of the attribute via db query. UPDATE
"public"."MODULE_attribute" SET "name" = 'test ' WHERE "name" = 'test'
3) Open Django admin panel and try to append any AttributeValue to 'test '
attribute.
4) I get the error message "Please correct the error below."

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

Django

unread,
Aug 8, 2018, 5:28:36 PM8/8/18
to django-...@googlegroups.com
#29647: "Please correct the error below." when saving edit model form with inline
formset and space at the end of primary key value
-------------------------------+--------------------------------------
Reporter: Alex Uralov | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution: invalid

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 Tim Graham):

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


Comment:

Yes, I can reproduce with those steps. Thanks. Inspecting the errors
manually, I see `[{'attribute': ['The inline value did not match the
parent instance.']}]`. I think the root cause is that the trailing space
is stripped in the parent instance but not for the child instance. I don't
think this is a bug in Django but it could be considered a duplicate of
#2259 in that the primary key probably shouldn't be editable in the first
place. I think you could fix that using `ModelAdmin.readonly_fields`.

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

Django

unread,
Aug 9, 2018, 3:24:25 AM8/9/18
to django-...@googlegroups.com
#29647: "Please correct the error below." when saving edit model form with inline
formset and space at the end of primary key value
-------------------------------+--------------------------------------
Reporter: Alex Uralov | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution: invalid

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 Alex Uralov):

Thank you for the advice!

--
Ticket URL: <https://code.djangoproject.com/ticket/29647#comment:4>

Reply all
Reply to author
Forward
0 new messages