import httplib2

def url_exists(url):
    """
    Check that a url- when following redirection - exists.
    This is needed because django's validators rely on python's urllib2
    which in verions < 2.6 won't follow redirects.
    """

    h = httplib2.Http()
    resp, content = h.request(url)
    h.follow_all_redirects = True
    return 200<= resp.status <400

import httplib2

def url_exists(url):
    """
    Check that a url- when following redirection - exists.
    This is needed because django's validators rely on python's urllib2
    which in verions < 2.6 won't follow redirects.
    """

    h = httplib2.Http()
    resp, content = h.request(url, method="HEAD")
    h.follow_all_redirects = True
    return 200<= resp.status <400

Make url field check work over head requests
Make url field check work over head requests

  import httplib2
  
  def url_exists(url):
      """
      Check that a url- when following redirection - exists.
      This is needed because django's validators rely on python's urllib2
      which in verions < 2.6 won't follow redirects.
      """
  
      h = httplib2.Http()
-     resp, content = h.request(url)
+     resp, content = h.request(url, method="HEAD")
      h.follow_all_redirects = True
      return 200<= resp.status <400
  
Make url field check work over head requests
## Code Before:
import httplib2

def url_exists(url):
    """
    Check that a url- when following redirection - exists.
    This is needed because django's validators rely on python's urllib2
    which in verions < 2.6 won't follow redirects.
    """

    h = httplib2.Http()
    resp, content = h.request(url)
    h.follow_all_redirects = True
    return 200<= resp.status <400

## Instruction:
Make url field check work over head requests
## Code After:
import httplib2

def url_exists(url):
    """
    Check that a url- when following redirection - exists.
    This is needed because django's validators rely on python's urllib2
    which in verions < 2.6 won't follow redirects.
    """

    h = httplib2.Http()
    resp, content = h.request(url, method="HEAD")
    h.follow_all_redirects = True
    return 200<= resp.status <400
