Opened 18 years ago

Closed 18 years ago

#3388 closed (invalid)

[patch] newforms: form.save() fails with DoesNotExist exception when form contains ForeignKey field

Reported by: anton@… Owned by: Adrian Holovaty
Component: Forms Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello everyone

SVN version of newforms contains a bug with merging Jeff Hilyard's patch: when one does form.save() with a form contained ForeignKey field, it fails with DoesNotExists exception.

Patch to fix it is attached.

Attachments (1)

quick-fix.patch (499 bytes ) - added by anton@… 18 years ago.
quick fix

Download all attachments as: .zip

Change History (5)

by anton@…, 18 years ago

Attachment: quick-fix.patch added

quick fix

comment:1 by anton@…, 18 years ago

Has patch: set

P.S. I've found it by comparing #3263 patch and svn code

comment:2 by anton@…, 18 years ago

Woops, sorry, i meant #3257

comment:3 by Adrian Holovaty, 18 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

Could you write a patch to the unit tests in tests/modeltests/model_forms/models.py?

comment:4 by anton@…, 18 years ago

Resolution: invalid
Status: newclosed

Adrian, sorry, it seems to be my mistake.
#3257 required clean_data to contain ForeignKey object (for example Writer object for Article, if we speak about unittests in tests/modeltests/model_forms/models.py), your current changes require it to contain ForeignKey object's id, so my code, based on #3257, failed and I sent this patch to fix it.
Is there any page that could explain your vision of future features to not make such mistakes again ? For example, I sent the patch #3370 (mysql should set 'charset': 'utf8' to connection attributes), with this patch my app works ok but 8 tests fail (db returns unicode), without it all tests passed but in my app i see a mess of national charset and unicode strings on one page.

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