Opened 15 years ago

Closed 15 years ago

#11682 closed (fixed)

[soc2009/admin-ui] index can be 0 causing saving model with inlines to fail

Reported by: Fred Bartle Owned by: nobody
Component: contrib.admin Version: soc2009/admin-ui
Severity: Keywords: admin-ui
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In forms/models.py r11400

678 	                try:
679 	                    if index:
680 	                        pk_value = self.get_queryset()[index].pk
681 	                    else:
682 	                        pk_value = None
683 	                except IndexError:
684 	                    pk_value = None

'index' can be zero and therefore evaluate to False, pk_value is set to None, and the hidden AutoField is rendered without a pk value, causing a save to fail.

I did not see soc2009/admin-ui in version dropdown, so I left version empty.

Attachments (1)

admin-ui-11682.diff (597 bytes ) - added by Fred Bartle 15 years ago.
Check if index is not None

Download all attachments as: .zip

Change History (4)

by Fred Bartle, 15 years ago

Attachment: admin-ui-11682.diff added

Check if index is not None

comment:1 by Fred Bartle, 15 years ago

Has patch: set

Not sure if this is the place to be filing tickets for SoC projects.

comment:2 by Fred Bartle, 15 years ago

Keywords: admin-ui added
Version: soc2009/admin-ui

comment:3 by Zain Memon, 15 years ago

Resolution: fixed
Status: newclosed

Thanks. Fixed in r11935.

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