Skip to content

Django_v5.0 #1915

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

Merged
merged 2 commits into from
Dec 6, 2023
Merged

Django_v5.0 #1915

merged 2 commits into from
Dec 6, 2023

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Dec 6, 2023

https://docs.djangoproject.com/en/5.0/releases/5.0/#features-removed-in-5-0

The undocumented django.utils.datetime_safe module is removed.

Any Django 5 projects that import haystack will fail without this change.

try: # datetime_safe was removed in Django 5.0
from django.utils import datetime_safe
except ImportError:
import datetime as datetime_safe
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at how Django made this replacement in its own code in django/django@46346f8ea0802, it looks like it is always related to producing strftime ouptut, which is not the case in that file. So I would simply replace this by import datetime and replacing datetime_safe occurrences later in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is always difficult to be confident about making changes to a project that is failing its CI. I have taken a lot of runs at fixing this project's GitHub Actions but cannot seem to find the magic combination.

I have been using this branch to get all pytests of my main project to pass...
Pipfile:

# django-haystack = "*"  # Currently incompatible with Django 5.0
django-haystack = {git = "https://github.com/cclauss/django-haystack.git@Django_v5"}

but now that they are passing, let's try todo as you suggest above.

@cclauss cclauss requested a review from acdha December 6, 2023 20:51
@cclauss
Copy link
Contributor Author

cclauss commented Dec 6, 2023

% git grep datetime_safe

haystack/backends/whoosh_backend.py:from django.utils.datetime_safe import date, datetime
test_haystack/whoosh_tests/test_whoosh_backend.py:from django.utils.datetime_safe import date, datetime

I did not change these instances because https://pypi.org/project/Whoosh has not been updated since 2016 and points to a nonexistent BitBucket repo however https://github.com/mchaput/whoosh still exists.

@cclauss cclauss marked this pull request as ready for review December 6, 2023 21:07
Copy link
Contributor

@claudep claudep left a comment

Choose a reason for hiding this comment

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

Thanks, i think it's a safe change.

I followed your trials to make the test suite pass, thanks so much. I guess I'll need to pray more so we finally find a way through :-)

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.

2 participants