0
votes

Whenever I try to run, I'm getting the following error described below. Already I researched a solution, but I can not make it work.

Exception Type: ValueError Exception Value:
ModelForm has no model class specified. Exception Location: /usr/local/lib/python2.7/dist-packages/django/forms/models.py in init, line 275 Python Executable: /usr/bin/python Python Version: 2.7.6

Erro Traceback

File "/home/ubuntu/workspace/envelope/views.py" in cad_professor 67. form = ProfessorForm()

File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in init 275. raise ValueError('ModelForm has no model class specified.')

views.py

@login_required(login_url='/login/')  
def cad_professor(request):
    context = {}
    if request.method == 'POST':
        form = ProfessorForm(request.POST)
        if form.is_valid():
            form.save()
            context['success'] = True
    else:
        form = ProfessorForm()
context['form'] = form
template_name = 'envelope/cad_professor.html'
return render(request,template_name , context)

forms.py

from django import forms
from .models import Professor

class ProfessorForm(forms.ModelForm):

    class meta:
        model = Professor
1

1 Answers

2
votes

Your meta spelling is wrong. Change to:

class ProfessorForm(forms.ModelForm):
    class Meta:
        model = Professor