blank=False,null=False not working in models code Django

class Url(models.Model):

This is my models code....and when i make an object with no arguments..the object is created and is saved to the DB even after writing blank=False,null=False and the URL is also not checked for existence.If i supply it a dead link, it works but it shouldn't!

What is the problem with my code?

Related Query: Now that in django 1.4, verify_exists has been can i check for validation in 1.4?


  1. As you've seen, django does not validate model on save() by default, but your database should've thrown an error when inserting NULL value, I would check the schema to be sure.
  2. Use URLValidator

So i got it working by modifying my 'url' to url=models.URLField(verify_exists=True,max_length=200,default=None,blank=False,unique=True) and validating it by object.clean_fields().

If you don't use valid values or empty values it throws errors like this

ValidationError: {'url': [u'This URL appears to be a broken link.'] }

ValidationError: {'url': [u'This field cannot be blank.'] }

Need Your Help

Preloading some images for listview with UniversalImageLoader

java android android-listview universal-image-loader

I am using Sergey Tarasevich's library Universal Image Loader in my Android project to load images into a ListView. At the moment I am loading my pictures in the getView() method in my adapter and