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

PolymorphicQuerySet: Prevent NoneType error in test___lookup #621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hll1682003
Copy link

Description:

This PR ensures that test___lookup only processes non-None source_expression values to prevent potential NoneType errors. The change adds a simple condition to check if source_expression is None before passing it to test___lookup.

Changes:

Added a None check for source_expression before calling test___lookup.
Why this is needed:

  • Prevents potential NoneType errors when evaluating query expressions.
  • Ensures test___lookup is only invoked with valid values.
  • Our unit tests start failing after migrating from Django 5.0.10 to 5.1.5 and start showing "AttributeError: 'NoneType' object has no attribute 'name'"
  • Inspired by this fix, which addressed a similar issue in django-polymorphic.

@hll1682003 hll1682003 force-pushed the fix/test_lookup_none_check branch from 40fa958 to ecb85b3 Compare February 5, 2025 22:30
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

Successfully merging this pull request may close these issues.

1 participant