newbie Django form not valid

i have this

class specForm(ModelForm):
    a = Doctors_list.objects.values_list('specialty', flat=True)
    specialty = forms.ModelChoiceField(queryset=a)
    class Meta:
        model = Doctors_list

and this

from django.shortcuts import render_to_response
from testApp.forms import specForm

def specForm (request):
    if request.method == 'POST':
        form = specForm(request.POST)
        if form.is_valid():
        form = specForm()
    return render_to_response('hello.html', {'form':form})

When i run it i get the folowing error: specForm() takes exactly 1 argument (0 given) , i suposse it's because it considers the formnot valid, why? How i fix it?


class Doctors_list(models.Model):

    name = models.CharField(max_length=30)
    specialty = models.CharField(max_length=15)
    hp_id = models.ManyToManyField(Health_plan)
    location = models.CharField(max_length=15)

    def __unicode__(self):

Any help appreciated


It is a name conflict between the method def specForm(request) and the actual object form class specForm. Try to rename one of these. My recommendation is to rename the method because it might be call from within only.

Hope it helps

Don't give your form class and your view the same name.

By convention, your form should be named SpecForm, your view spec_form (or even better, something like update_specialty), and your model Doctor.

Need Your Help

Change color in emacs of highlight-indentation package

emacs elisp syntax-highlighting

It says you can use the highlight-indent-face but I'm not sure how to set this variable. Or what to change it to in the *.el. I use a white background so the lines are barely visible. A darker gray...