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: | 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)
Change History (5)
by , 18 years ago
Attachment: | quick-fix.patch added |
---|
comment:3 by , 18 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Could you write a patch to the unit tests in tests/modeltests/model_forms/models.py
?
comment:4 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.
quick fix