Django

Code

Changeset 3109

Show
Ignore:
Timestamp:
06/07/06 22:47:18 (3 years ago)
Author:
adrian
Message:

Solved the POST-data-lost-after-redirect problem by raising RuntimeError? when DEBUG=True in the CommonMiddleware?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/middleware/common.py

    r2809 r3109  
    4040        if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]): 
    4141            new_url[1] = new_url[1] + '/' 
     42            if settings.DEBUG and request.META['REQUEST_METHOD'].lower() == 'post': 
     43                raise RuntimeError, "You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to %s%s (note the trailing slash), or set APPEND_SLASH=False in your Django settings." % (new_url[0], new_url[1]) 
    4244        if new_url != old_url: 
    4345            # Redirect