djangodjango-modelsdjango-1.3

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


class Url(models.Model):
    url=models.URLField(verify_exists=True,max_length=200,blank=False,null=False)
    date=models.DateTimeField(auto_now_add=True)
    count=models.IntegerField(default=0)
    isspam=models.IntegerField(default=0)

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 deprecated...how can i check for validation in 1.4?


Solution

    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