Django ValueError: ModelForm has no model class specified
<p>I have the following code which complains about the following error:</p>

<p>ValueError: ModelForm has no model class specified.</p>

<pre><code>from django import forms
from straightred.models import StraightredTeam
from straightred.models import UserSelection



class SelectTwoTeams1(forms.Form):

    campaignnoquery = UserSelection.objects.filter(user=349).order_by('-campaignno')[:1]
    currentCampaignNo = campaignnoquery[0].campaignno
    cantSelectTeams = UserSelection.objects.filter(campaignno=currentCampaignNo)

    currentTeams = StraightredTeam.objects.filter(currentteam = 1).exclude(teamid__in=cantSelectTeams.values_list('teamselectionid', flat=True))
    team_one = forms.ModelChoiceField(queryset = currentTeams)
    team_two = forms.ModelChoiceField(queryset = currentTeams)



class SelectTwoTeams(forms.ModelForm):
    used_his = forms.ModelMultipleChoiceField(queryset=UserSelection.objects.filter(user__id=1))

    def __init__(self, user, *args, **kwargs):
        super(SelectTwoTeams, self).__init__(*args, **kwargs)
        self.fields['used_his'].queryset = User.objects.filter(pk = user.id)
</code></pre>

<p>Any help would be greatly appreciated. Many thanks, Alan.</p>

<p>The error message is clearly telling you that you have not specified a model class.</p>

<p>For a ModelForm, you have to use Model class:</p>

<pre><code>class ProductForm(forms.ModelForm):
    class Meta:
        model = Product
</code></pre>

<p>If this isn't a form based on a model, don't inherit from forms.ModelForm, just use an ordinary forms.Form.</p>

python django