exclude() method in Django

You can exclude certain results from the QuerySet using the exclude() method of the manager. For Ex:, you can retrieve all posts published in 2019 whose titles don't start with xyz:

  • Posts.objects.filter(publish__year=2019).exclude(title__startswith='xyz') 

Comments

Popular posts from this blog

Advantages to using URLField() over TextField()

Forms in Django(bound, unbound, clean, is_valid, errors)