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

Replaced usage of deprecated function get_fields_with_model with new … #3052

Merged
merged 4 commits into from
Dec 5, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion readthedocs/builds/version_slug.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
from builtins import range


def get_fields_with_model(cls):
return [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a prescribed Django fix for this, perhaps link to the permalink in docs here to explain what this is for.

(f, f.model if f.model != cls else None)
for f in cls._meta.get_fields()
if not f.is_relation or f.one_to_one or
(f.many_to_one and f.related_model)
]


# Regex breakdown:
# [a-z0-9] -- start with alphanumeric value
# [-._a-z0-9] -- allow dash, dot, underscore, digit, lowercase ascii
Expand Down Expand Up @@ -59,7 +68,7 @@ def __init__(self, *args, **kwargs):

def get_queryset(self, model_cls, slug_field):
# pylint: disable=protected-access
for field, model in model_cls._meta.get_fields_with_model():
for field, model in get_fields_with_model(model_cls):
if model and field == slug_field:
return model._default_manager.all()
return model_cls._default_manager.all()
Expand Down