tolomea / django-auto-prefetch

Automatically prefetch foreign key values as needed
BSD 3-Clause "New" or "Revised" License
356 stars 7 forks source link

base_manager_name check fails since 1.5.1 #235

Open benedikt-bartscher opened 1 year ago

benedikt-bartscher commented 1 year ago

Python Version

3.11

Django Version

4.1.7

Package Version

1.5.1

Description

Since 1.5.1 i get a warning like this for all my models using django-auto-prefetch:

vote.Question: (auto_prefetch.E001) Question inherits from auto_prefetch.Model but its base_manager_name is not 'prefetch_manager'
    HINT: The base_manager_name is instead None. Check the Meta class inherits from auto_prefetch.Model.Meta.
seporaitis commented 1 year ago

@benedikt-bartscher Could you share a simple example that recreates the problem? Thanks!

adamchainz commented 1 year ago

@benedikt-bartscher set it explicitly:

class MyModel(...):
    class Meta:
        base_manager_name = 'prefetch_manager'

The check exists because without the meta option set, auto-prefetching won't be performed for related manager querysets.

adamchainz commented 1 year ago

I've opened #236 to tweak the message from this check.