
class FormWithRequestMixin(object):
    def get_form_kwargs(self, **kwargs):
        kwargs = super(FormWithRequestMixin, self).get_form_kwargs(**kwargs)
        kwargs['request'] = self.request
        return kwargs


class FormWithPrefixMixin(object):
    # deprecated after Django 1.6
    prefix = None

    def get_form_kwargs(self, **kwargs):
        kwargs = super(FormWithPrefixMixin, self).get_form_kwargs(**kwargs)
        kwargs['prefix'] = self.prefix
        return kwargs

class FormWithPostTarget(object):
    def get_form_kwargs(self, **kwargs):
        kwargs = super(FormWithPostTarget, self).get_form_kwargs(**kwargs)
        if not self.is_post_target():
            kwargs.pop('data', None)
            kwargs.pop('files', None)
        return kwargs
