File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ class Meta:
54
54
55
55
def __init__ (self , * args , ** kwargs ):
56
56
super (UserChangeForm , self ).__init__ (* args , ** kwargs )
57
- self .fields ['user_permissions' ].queryset = self .fields ['user_permissions' ].queryset .select_related ('content_type' )
57
+ f = self .fields .get ('user_permissions' , None )
58
+ if f is not None :
59
+ f .queryset = f .queryset .select_related ('content_type' )
58
60
59
61
class AuthenticationForm (forms .Form ):
60
62
"""
Original file line number Diff line number Diff line change @@ -199,6 +199,22 @@ def test_username_validity(self):
199
199
self .assertEqual (form ['username' ].errors ,
200
200
[u'This value may contain only letters, numbers and @/./+/-/_ characters.' ])
201
201
202
+ def test_bug_14242 (self ):
203
+ # A regression test, introduce by adding an optimization for the
204
+ # UserChangeForm.
205
+
206
+ class MyUserForm (UserChangeForm ):
207
+ def __init__ (self , * args , ** kwargs ):
208
+ super (MyUserForm , self ).__init__ (* args , ** kwargs )
209
+ self .fields ['groups' ].help_text = 'These groups give users different permissions'
210
+
211
+ class Meta (UserChangeForm .Meta ):
212
+ fields = ('groups' ,)
213
+
214
+ # Just check we can create it
215
+ form = MyUserForm ({})
216
+
217
+
202
218
class PasswordResetFormTest (TestCase ):
203
219
204
220
fixtures = ['authtestdata.json' ]
You can’t perform that action at this time.
0 commit comments