Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 2.0 Warning: use_for_related_fields is deprecated #290

Closed
clokep opened this issue Sep 15, 2017 · 4 comments
Closed

Django 2.0 Warning: use_for_related_fields is deprecated #290

clokep opened this issue Sep 15, 2017 · 4 comments

Comments

@clokep
Copy link

clokep commented Sep 15, 2017

Problem

Using the InheritanceManager on a class causes the following warning:

/usr/local/venv/local/lib/python2.7/site-packages/django/db/models/fields/related_descriptors.py:157: RemovedInDjango20Warning: use_for_related_fields is deprecated, instead set Meta.base_manager_name on 'my_app.MyModel'.
  qs = self.get_queryset(instance=instance)

This seems to be used in a couple of places:

I'm not really sure of the ramifications of just removing this vs. using Meta.base_manager_name, etc. I know there's some special things done with the first Manager found on a Django Model class.

Environment

  • Django Model Utils version: 3.0.0
  • Django version: 1.11.5
  • Python version: 2.7.6
@tony
Copy link
Member

tony commented Dec 4, 2017

We need a game plan for this then. 😄 2.0 was released yesterday

@tony tony mentioned this issue Dec 7, 2017
4 tasks
@tony
Copy link
Member

tony commented Dec 7, 2017

More lore:

django/django@ed0ff91

Old API:

class CustomManager(models.Model):  # (sic, pretty sure they meant models.Manager)
    use_for_related_fields = True

class Model(models.Model):
    custom_manager = CustomManager()

New API:

class Model(models.Model):
    custom_manager = CustomManager()

    class Meta:
        base_manager_name = 'custom_manager'

tony added a commit to develtech/django-model-utils that referenced this issue Dec 7, 2017
@bahendri
Copy link

Seems like this issue should be closed in light of c4d7212.

(In my app, pytest threw this deprecation warning and a quick read seemed to suggest the problem was in this library but I later realized it was my app's fault. If this ticket had been marked closed I might have realized my mistake sooner.)

@auvipy auvipy closed this as completed Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants