-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autostrip decorator doesn't work in ModelAdmin #2
Comments
Hmm, I see. Any idea why that's happening? |
My guess is that Django Admin use ModelForm in a different way from what we usually do. The mechanism of autostrip decorator is it injects clean methods on CharFields of the form on initialization. But Admin will probably ignore them because it initializes form in a different way. Without digging into the source code, that's just my wild assumption. Actually I change the lambda inside the decorator to a named function so that I can print something. When I create a form instance, it does print what I expect. While in Admin, these print statements are never called. |
Ah, it does sound like the ModelAdmin doesn't call the |
clean() method is called in ModelAdmin. But I have the feeling that it's not the one injected by the decorator. |
If I add autostrip decorator on a ModelForm and call is_valid method on the form in my own view, white spaces are stripped correctly. But if I tell a ModelAdmin to use this decorated form as the form, white spaces won't be stripped when I edit the model and save inside Admin pages.
The text was updated successfully, but these errors were encountered: