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

Internationalization (Language Setting) in Django

reverse_lazy() Method in Django

CharFilter in Django