queryset refactor

    The long awaited queryset-refactor branch is finally merged with the main working trunk branch (change r7477). The official documentation for the trunk on the site is also updated.
    What does this mean for all of us?
    • The most important thing is, of course, model inheritance . Models can be inherited from each other, and thus the corresponding tables in the database will refer to each other, respectively.
    • The base classes can be abstract (in this case, no separate table will be created for them, and the fields defined in them will be created in the descendant model table), or they may not be (and then the descendant model table will refer to the base table).
    • Inheritance, by the way, can be multiple .
    • OneToOneField fields no longer automatically create a primary key. Be careful, this is a change with loss of backward compatibility.
    • Q objects can now be used with the &, | and ~, and the result will also be a Q-object.
    • .filter (field = None) (or .filter (field__exact = None)) is now equivalent to .filter (field__isnull = True).
    • Now the QuerySet has an update () method that allows you to change something at once for all the fields corresponding to the QuerySet.

    ... well, and many other interesting things , but it’s worth mentioning separately the undocumented nice bauble - .query and .query.as_sql () for any QuerySets — now it becomes clear which SQL is generated during complex queries ...

    Also popular now: