Code

Opened 7 years ago

Closed 7 years ago

#3388 closed (invalid)

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

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

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@… 7 years ago.
quick fix

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by anton@…

quick fix

comment:1 Changed 7 years ago by anton@…

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 7 years ago by anton@…

Woops, sorry, i meant #3257

comment:3 Changed 7 years ago by adrian

  • Needs tests set
  • Triage Stage changed from Unreviewed to Accepted

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

comment:4 Changed 7 years ago by anton@…

  • Resolution set to invalid
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.