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

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
@selwin
Contributor

selwin commented Aug 20, 2012

Hi there,

Attached is a patch and testcase that fixes https://code.djangoproject.com/ticket/6702 . Let me know if there's anything else that needs changing.

Best,
Selwin

@@ -114,6 +114,10 @@ def test_unicode_filename(self):
self.assertEqual(m.file.name, 'tests/\u6211\u96bb\u6c23\u588a\u8239\u88dd\u6eff\u6652\u9c54.txt')
m.delete()
+ def test_incorrect_instance_raises_exception(self):
+ # ModelForm with incorrect instance raises ValueError on init ##########

This comment has been minimized.

@apollo13

apollo13 Aug 31, 2012

Member

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

@apollo13

apollo13 Aug 31, 2012

Member

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

This comment has been minimized.

@selwin

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?

@selwin

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?

This comment has been minimized.

@apollo13

apollo13 Aug 31, 2012

Member

Yes that would be great (also the other occurences in that file). Btw Malcom said the assert was okay: https://code.djangoproject.com/ticket/6702#comment:3 -- Why do you use an insinstance check in your patch?

@apollo13

apollo13 Aug 31, 2012

Member

Yes that would be great (also the other occurences in that file). Btw Malcom said the assert was okay: https://code.djangoproject.com/ticket/6702#comment:3 -- Why do you use an insinstance check in your patch?

This comment has been minimized.

@selwin

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.

@selwin

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.

@timgraham

This comment has been minimized.

Show comment
Hide comment
@timgraham

timgraham May 31, 2013

Member

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

Member

timgraham commented May 31, 2013

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

@timgraham timgraham closed this May 31, 2013

sztrovacsek pushed a commit to sztrovacsek/django that referenced this pull request Mar 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment