pythondotorg icon indicating copy to clipboard operation
pythondotorg copied to clipboard

Fix OrderedModelManager warnings in Sponsorship models (#2743)

Open MisbahAN opened this issue 4 months ago • 1 comments

Overview

This PR resolves the warning (ordered_model.W003) for both SponsorshipBenefit and SponsorshipPackage models. These models subclass OrderedModel but were previously using managers that did not inherit from OrderedModelManager.

Changes Made

  • Updated SponsorshipPackage to use OrderedModelManager.from_queryset(SponsorshipPackageQuerySet)()
  • Updated SponsorshipBenefit to use OrderedModelManager.from_queryset(SponsorshipBenefitQuerySet)()
  • Added necessary import for OrderedModelManager

Why This Fixes the Warning

Using .as_manager() does not ensure that the resulting manager inherits from OrderedModelManager, even if the queryset does. Using .from_queryset() ensures the manager inherits from OrderedModelManager while preserving custom queryset functionality.

Fixes #2743

MisbahAN avatar Jul 30 '25 22:07 MisbahAN

hi @JacobCoffee and @ewdurbin, just wanted to follow up on this PR (#2743) when you get a chance. This is my FIRST open-source contribution and I’d love any feedback or direction if anything needs to be changed. TYIA!!

MisbahAN avatar Aug 02 '25 19:08 MisbahAN