Fix for #6702: ModelForm now checks instance on __init__ #296

wants to merge 2 commits into


None yet

3 participants

selwin commented Aug 20, 2012

Hi there,

Attached is a patch and testcase that fixes . Let me know if there's anything else that needs changing.


@apollo13 apollo13 and 1 other commented on an outdated diff Aug 31, 2012
@@ -114,6 +114,10 @@ def test_unicode_filename(self):
self.assertEqual(, 'tests/\u6211\u96bb\u6c23\u588a\u8239\u88dd\u6eff\u6652\u9c54.txt')
+ def test_incorrect_instance_raises_exception(self):
+ # ModelForm with incorrect instance raises ValueError on init ##########
apollo13 Aug 31, 2012 Member

What's with the hashes (#) at the end?

selwin Aug 31, 2012 Contributor

The tests surrounding it have comments ending with multiple hashes so I was just following those (Lines 109 and 122). Want me to remove them?

apollo13 Aug 31, 2012 Member

Yes that would be great (also the other occurences in that file). Btw Malcom said the assert was okay: -- Why do you use an insinstance check in your patch?

selwin Aug 31, 2012 Contributor

@apollo13 I just updated my branch to clean the extra hashes. I raised ValueError because it's more consistent with the rest of ModelForm (raises ValueError when no model is specified and when save is called when the form doesn't validate.


Ticket has been marked as "won't fix."

@timgraham timgraham closed this May 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment