Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3301174
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:43:36+00:00 2026-05-17T20:43:36+00:00

so…i’ve been banging my head on this for a bit. I’m getting the most

  • 0

so…i’ve been banging my head on this for a bit. I’m getting the most bizarre error when attempting to validate a form. I pass input to the form wanting to test behavior when the form fails validation, i.e. i expect it to fail validation.

i’ve got this code for a form:

class CTAForm(forms.Form):      
    first_name = forms.CharField(max_length=50)
    email = forms.EmailField()
    phone = forms.CharField(max_length=15, required=False, label='Phone (optional)')

And i make this call somewhere in a view in order to process the form data.

if cta_form.is_valid():

and i get:

Exception Type:     TypeError
Exception Value:    'str' object is not callable
Exception Location:     /usr/lib/pymodules/python2.6/django/forms/forms.py in full_clean, line 246

Traceback shows this:

/usr/lib/pymodules/python2.6/django/forms/forms.py
in full_clean:

  1. except ValidationError, e:
  2. self._errors[name] = self.error_class(e.messages) …

▼ Local vars
Variable Value
e: ValidationError()
field: django.forms.fields.EmailField object at <0x225c4d0c>
name: ’email’
self: blah.views.CTAForm object at <0x2245b42c>
value: u’ ‘

I’m feeling quite stupid. Anyone provide me with guidance on this issue? thanks.


edit: more complete view code as requested

def cta_add(request):
    context_dict = {'categories': Category.objects.all().order_by('order'),}
    # we always expect to receive data via post
    if request.method =='POST':
        # get the current vid based on the parameter        
        current_vid = Video.objects.get(slug=request.POST['current_vid'])           
        # use this video to create our dynamic form so we get the valid cta values based on that video
        cta_form_class = make_cta_form(current_vid.cta_set.all().order_by('order'))
        # instantiate our new dynamic form based on the post data
        cta_form = cta_form_class(request.POST,  error_class='error')

        # if we got this far, we were able to generate a form to validate the user's input against.
        # If form validates, than process and take user to success screen           
        if cta_form.is_valid():

helper function make_cta_form below

def make_cta_form(cta_set):
    cta_list =[]
    if not cta_set is None:
        for cta in cta_set:
            cta_list.append((cta.text, cta.text))

    class CTAForm(forms.Form):
        cta = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=cta_list, label='', required=False)
        first_name = forms.CharField(max_length=50)
        email = forms.EmailField()
        phone = forms.CharField(max_length=15, required=False, label='Phone (optional)')        

    return CTAForm
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:43:37+00:00Added an answer on May 17, 2026 at 8:43 pm

    You get an error about a string not being callable, but your errorclass for your form is a string, not an error class.

        cta_form = cta_form_class(request.POST,  error_class='error')
    

    Now the only reference in the docs I can find for error_class is as a list of strings, so you may just try

        cta_form = cta_form_class(request.POST,  error_class=['error'])
    

    Though it seems to make more sense to do something like

        import forms 
        [...]
        cta_form = cta_form_class(request.POST,  error_class=forms.ValidationError("error"))
    

    or possibly:

        cta_form = cta_form_class(request.POST,  error_class=forms.ValidationError)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CGI.escapeHTML is pretty bad, but CGI.unescapeHTML is completely borked. For example: require 'cgi' CGI.unescapeHTML('&#8230;')
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
An Arabic name shall be sent via SOAP. The name is encoded like this:
I have a form, one of the fields is a select field, with 5
I have a MySQL query: SELECT px.player, px.pos, px.year, px.age, px.gp, px.goals, px.assists ,
I see that some rss on xml have strange strings. For example, ... is
I want to open a popup window of an Image on More Info link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.