Ah. I think the method is overriding the edit page. In other words, you have click on the editpage to see the effect of my fail code. So it doesn't trigger if you are on the list view page. Does anyone know what to do with the editable submission? It should use the same clean_ method, shouldn't it??
On Sunday, July 8, 2012 9:33:49 AM UTC-4, dd wrote: > > Django has list_editable. I need to edit is_active flag. > > class MyUserAdminForm(ModelForm): > class Meta: > model = User > > def clean_is_active(self): > # do something that validates your data > print ' I am here... ' > print self.cleaned_data > print self > > class MyUserAdmin(admin.ModelAdmin): > .... SOME CODE .... > form = MyUserAdminForm > > > admin.site.unregister(User) > admin.site.register(User, MyUserAdmin) > > I put this in admin.py, and I've registered my admin.ModelAdmin code. The > display is fine. > > The code above should fail because it doesn't return > self.cleaned_data["is_active"]. But when I reload the development server, > and changed the flag on some users, Django didn't complain, so this piece > of code is not used. > > My requirement is to check that the user under change is not a superuser. > I have other things to do within that validation, but you get the idea. > > Why is this? > > Thanks. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/R9svhH1WS00J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.