-
-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for inline
from_queryset
in model classes (#1045)
* Add support for inline from_queryset in model classes This adds support for calling <Manager>.from_queryset(<QuerySet>)() inline in models, for example like this: class MyModel(models.Model): objects = MyManager.from_queryset(MyQuerySet)() This is done by inspecting the class body in the transform_class_hook * Fix missing methods on copied manager * Add test and other minor tweaks * Always create manager at module level When the manager is added at the class level, which happened when it was created inline in the model body, it's not possible to retrieve the manager again based on fullname. That lead to problems with inheritance and the default manager.
- Loading branch information
Showing
7 changed files
with
244 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.