Improved BootstrapMixin so it could be used to decorate existing form with minimal effort #43

merged 1 commit into from Mar 12, 2012


None yet

2 participants


This change allows user to decorate existing forms easier. Let's say, a user wants to make django.contrib.auth.forms.AuthenticationForm pretty. Now he just needs to define a class like this:

class LoginForm(BootstrapMixin, AuthenticationForm):

add Meta class if he wants to, and use resulting form in his view.
No more need to call AuthenticationForm.__init__() and BootstrapMixin.__bootstrap__() in constructor.
The only drawback I see is that BootstrapMixin must be the first base class, which is not intuitively obvious. The problem is that BaseForm class does not call parent's constructor. I've tried to use metaclasses to change base class order on the fly, but did not succeed, at least with reasonable amount of code.
Also I believe that using double underscored method names such as __bootstrap__ is not the best idea, since this naming convention is intended for python magic and python internals.

@earle earle merged commit 520a59f into earle:master Mar 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment