I need to check whether the given url is valid or not in django. I have used URLValidator for checking the url in django. But it's not working. I have explained the code below.
from django.core.validators import URLValidator
from django.core.exceptions import ValidationError
a = "www.google.com"
url = URLValidator()
try:
url(a)
print "correct"
except:
print "wrong"
When i tried to run the above concept it's showing the output "wrong". And then when i passed the value of a="http://www.google.com" means that the output is "correct". After that when i passed the value of a="http://www.googlecom" means that the output is "correct" .am more confused with it. Please anyone help me to do this concept.
Thanks in advance.