from django.core.validators import URLValidator() validate = URLValidator() try: validate("http://www.avalidurl.com/") print("String is a valid URL") except ValidationError as exception: print("String is not valid URL")