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 8379055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:04:34+00:00 2026-06-09T16:04:34+00:00

I am using earle / django-bootstrap to show a form styled with twitter bootstrap.

  • 0

I am using earle / django-bootstrap to show a form styled with twitter bootstrap. I want to be able to change the style and show the errors the user committed while filling the form (i.e. if he missed a required field)

I cannot find in the documentation on how to output errors. I am submitting the form using jquery.form.js and returning errors in an array in a dictionary, the problem is, the errors array returns empty, and even printing the errors array in the view shows it empty.

The code for the form:

class SomeForm(BootstrapForm):
    class Meta:
        layout = (
        Fieldset( "Form title:","first_field", "second_field", ),
    )

    first_field = forms.CharField(label=u'Some Text', max_length=50,    error_messages={'required':u'The error msg',},required=True,)
    second_field = forms.ModelChoiceField(label=Some Text', queryset=SomeClass.objects.all(), error_messages={'required':u'The error msg. ',}, required=True, )

And the code for the view:

@login_required
def new_case(request):
    if request.method == 'POST':
        form = SomeForm(request.POST)
        if form.is_valid():
            new_case = form.save(request.user)
            return HttpResponseRedirect('/casos/')
        else:
            response_dict = {'ok': False, 'msg': None, 'err': None,}
            err = {}
            caseErrors = {}
            caseErrors.update(form.errors)
            for field in caseErrors:
                caseErrors[field] = [unicode(error) for error in caseErrors[field]] 
            err['caso']=caseErrors   
            response_dict['msg'] = u'The fields are not valid.'
            response_dict['err'] = err
            return HttpResponse(simplejson.dumps(response_dict), mimetype='application/json')
    else:
        form = SomeForm()
        return render_to_response('casos/new_case.html', { 'form': form },    context_instance=RequestContext(request))

Also the jQuery

<script type="text/javascript" src="{{ STATIC_URL }}jquery/jquery.form.js"></script>
<script type="text/javascript">

$(function() {
    $('#agr_ncaso').ajaxForm({
        dataType: 'json',
        beforeSubmit: before_submit,
        success: success
    });
});

function before_submit(formData, jqForm, options) {
    $('.error').removeClass('error');
    $('.alert-error').remove();
    return true; 
}

function success(json) {
    if (json.ok) {
        window.location = '/casos/';
    }
    else if (json.err) {            
        $('<div class="alert alert-error"><strong>Error inform </strong></div>').insertBefore('form')       
        for (campo in json.err) {
        $('#div_id_' + campo).addClass("error");
        }
        $('.alert').fadeIn('slow');
    }
    else {
        alert(json.msg);
    }
}
  • 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-06-09T16:04:36+00:00Added an answer on June 9, 2026 at 4:04 pm

    The errors of the form are inside err[‘casos’], not inside err. Have a great day

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using a populated Table Type as the source for a TSQL-Merge. I want to
Using the Redis info command, I am able to get all the stats of
I am in the early stages of building an app using Rails 3. User
I'm wondering about the advantages of using (django) South during heavy initial development of
I'm using jQuery (1.4.2) with a Django backend and doing my development with Firefox
I've started learning using Django with Cassandra. I will develop many websites on Cassandra,
Using the dragenter event I show a dropzone on the webpage to have dropped
I'm using shadowbox js for showing Flash video in lightbox style popups. So far
I'm using JSF 2.0 and I want to flush the buffer early (between head
I am trying to get a plugin from a pluginassembly object using early bindings.

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.