Ticket #17650: baseform_contains.diff
File baseform_contains.diff, 1.3 KB (added by , 13 years ago) |
---|
-
django/forms/forms.py
101 101 for name in self.fields: 102 102 yield self[name] 103 103 104 def __contains__(self, name): 105 return name in self.fields 106 104 107 def __getitem__(self, name): 105 108 "Returns a BoundField with the given name." 106 109 try: -
tests/regressiontests/forms/tests/forms.py
42 42 self.assertHTMLEqual(str(p['first_name']), '<input type="text" name="first_name" value="John" id="id_first_name" />') 43 43 self.assertHTMLEqual(str(p['last_name']), '<input type="text" name="last_name" value="Lennon" id="id_last_name" />') 44 44 self.assertHTMLEqual(str(p['birthday']), '<input type="text" name="birthday" value="1940-10-9" id="id_birthday" />') 45 self.assertTrue('first_name' in p) 46 self.assertFalse('nonexistentfield' in p) 45 47 try: 46 48 p['nonexistentfield'] 47 49 self.fail('Attempts to access non-existent fields should fail.')