Error in Django Module

Asked

Viewed 151 times

2

Whenever I try to run, I’m getting the following error described below. I’ve already searched a solution, but I can’t make it work.

Exception Type: Valueerror Exception Value:
Models in the specified class model. 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

py views.

@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
  • the code is formatted exactly like your?

  • Sorry, I fixed that yes

2 answers

0


@Theuzc,

your meta actually is Meta.

Try it there:

class ProfessorForm(forms.ModelForm):

    class Meta:
        model = Professor

0

True, I got it this way

class Meta:
    model = Professor
    fields = '__all__'      << Django estava pedido

and models had a statement to the wrong bank, so when I was going to access it didn’t exist and made a mistake for not finding

Browser other questions tagged

You are not signed in. Login or sign up in order to post.