1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
import warnings
from django.forms import models
from .fields import Field
from .forms import LayoutRenderer
from .widgets import Select, SelectMultiple
__all__ = ('ModelForm', 'ModelChoiceField', 'ModelMultipleChoiceField')
class ModelForm(LayoutRenderer, models.ModelForm):
def __new__(cls, *args, **kwargs):
url = 'https://github.com/gregmuellegger/django-floppyforms/tree/1.2.0/CHANGES.rst'
warnings.warn(
'The behaviour of subclasses of floppyforms.models.ModelForm will '
'change with django-floppyforms 1.3. '
'Use `import floppyforms.__future__ as forms` instead of '
'`import floppyforms as forms` to use the new behaviour now. '
'See announcement here: %s' % url,
FutureWarning)
return super(ModelForm, cls).__new__(cls, *args, **kwargs)
class ModelChoiceField(Field, models.ModelChoiceField):
widget = Select
class ModelMultipleChoiceField(Field, models.ModelMultipleChoiceField):
widget = SelectMultiple
|