title: How to reopen a Django form in a jQuery dialog when the form validation fails in the backend?
body: <p>I have a Django form which I load dynamically to a jQuery dialog after a user has clicked a link on a webpage. The href in the link points to a Django page that contains just the form contents, not the whole site layout.</p>
  
  <pre>
          $('#add-note').click(function() {
              $('#dialog').load($(this).attr('href')).dialog({
                  title: 'Add a note',
                  modal: true,
                  draggable: false,
                  minWidth: 500,
              });
  
              return false;
          });
  </pre>
  
  <p>This works fine if the user submits a form that validates in the backend. However, if the form contains validation errors, Django forwards the browser back to the form page, which in this case is not actually the page the user was viewing at the moment.</p>
  
  <p>See, the user was on a totally different page and the form was just dynamically loaded to the jQuery dialog. So the question is, what would be the best way to handle this kind of situation? How do I open the form with validation errors back in to the dialog and not the form page itself?</p>
  
  <p>All help appreciated greatly!</p>