Skip to content

Isnull filter and complex filters (including or)

Compare
Choose a tag to compare
@collerek collerek released this 09 Mar 09:32
· 936 commits to master since this release
d7931a2

0.9.7

Features

  • Add isnull operator to filter and exclude methods.
    album__name__isnull=True #(sql: album.name is null)
    album__name__isnull=False #(sql: album.name is not null))
  • Add ormar.or_ and ormar.and_ functions that can be used to compose
    complex queries with nested conditions.
    Sample query:
    books = (
        await Book.objects.select_related("author")
        .filter(
            ormar.and_(
                ormar.or_(year__gt=1960, year__lt=1940),
                author__name="J.R.R. Tolkien",
            )
        )
        .all()
    )
    Check the updated docs in Queries -> Filtering and sorting -> Complex filters

Other

  • Setting default on ForeignKey or ManyToMany raises and ModelDefinition exception as it is (and was) not supported