copied wholesale from django.forms.models.modelform_factory and adapted for BetterModelForm