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

  • Home
  • SEARCH
  • 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 6103627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:45:01+00:00 2026-05-23T13:45:01+00:00

I am using this code if form.is_valid(): form.save() if request.POST.get(‘ajax’) == ‘true’: return HttpResponse(‘Data

  • 0

I am using this code

if form.is_valid(): 
            form.save()
            if request.POST.get('ajax') == 'true':
                return HttpResponse('Data Entered Successfully') # Redirect after POST
            else:
                return HttpResponseRedirect('/thanks/') # Redirect after POST

I am submitting the form via jquery POST method.

The problem is whenever i have some error like indentation , or model error then i don’t get anything back. i had to test the page by disabling ajax and submit via normal method and then i see the yellow django error page and then i correct the error.

is there any way that Even if i get any error i see that as response to jquery

  • 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-23T13:45:02+00:00Added an answer on May 23, 2026 at 1:45 pm

    In general you could register your own handler500 and test if the request is ajax and then from that return an ajax error response that indicates what happened if DEBUG is True, or just gives a general error if DEBUG is False.

    The other options are to either use Firebug or Chrome Inspector to browse the Ajax response, or to setup some form of logging that logs the errors which is useful even when the site is deployed in order to do a post mortem on any errors that might occur.

    Django itself has built in logging capabilities, one of which is sending an email to admins, but you can define your own using Django’s integration with Python’s built in logging. One option for a handler for these is django-sentry which I use on all my production sites to record any error that happens and also includes the ability to override the handler500 to give the end user a reference number that can be used to look up their exact error instance.

    Sentry comes with 2 apps, one is the server, and one is the client. In a typical production setting when you have multiple machines serving the same site, you will have a dedicated sentry server that only does sentry. However for a single site having it integrated in with the site is ok.

    To configure sentry you’ll need to add both sentry (the server) and sentry.client (the client) to your INSTALLED_APPS. Then you’ll need to configure your logging.

    Here is an example:

    LOGGING = {
        "version": 1,
        "disable_existing_loggers": False,
    
        "handlers": {
            "mail_admins": {
                "class": "django.utils.log.AdminEmailHandler",
                "level": "ERROR"
            },
            "sentry": {
                "class": "sentry.client.handlers.SentryHandler",
                "level": "ERROR",
            }
        },
    
        "loggers": {
            "django.request": {
                "handlers": ["sentry", "mail_admins"],
                "level": "ERROR",
                "propagate": True
            }
        },
    }
    

    The above example will still email admins if an error occurs and DEBUG = False. If you do not want it to do that, remove mail_admins from the handlers on django.request.

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

Sidebar

Related Questions

I'm using this code in one of my views: if request.method == 'POST': vehicle
I'm using this code, to make a request to a given URL: private static
I'm using this code, and I get the stack trace that is listed below.
I am using this code to get the background image of a div .
Using this code to zip a folder and it works perfect on small files
Im using this code for mysql connection $con = mysql_connect(localhost:/var/lib/mysql/mysql.sock, abc , xyz); if
While using this code to serialize an object: public object Clone() { var serializer
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1
Im using this code: $(this).css('backgroundcolor', localStorage.getItem('bgColorr') + !important;); When i write: alert( localStorage.getItem('bgColorr') +
I'm using this code from Microsoft to play audio notifications for my application. It's

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.