Fixed #15877 -- Improved exception when ModelForm has no model class

Thanks theaspect at gmail.com for the report and volrath for the
patch.