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 5.0 Tracking Issue #1493

Open
2 of 39 tasks
adamchainz opened this issue May 12, 2023 · 21 comments
Open
2 of 39 tasks

Django 5.0 Tracking Issue #1493

adamchainz opened this issue May 12, 2023 · 21 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@adamchainz
Copy link
Contributor

adamchainz commented May 12, 2023

This is a tracking issue for changes that will be needed for Django 5.0, based on in-development release notes.

EDIT: Please see #1493 (comment) for an up to date progress list.

(Collapsed original list that is now outdated)
  • warnings in django.utils.deprecation
  • admin facets - ModelAdmin.show_facets, django.contrib.admin.ShowFacets enum
  • form field groups - BoundField.as_field_group(), django.forms.Field.template_name, django.forms.renderers.BaseRenderer.field_template_name
  • Database-computed default values - db_default arg and attr on model Field
  • django.contrib.admin.AdminSite.get_log_entries
  • django.http.HttpRequest.auser from AuthenticationMiddleware
  • django.contrib.gis.db.models.functions.ClosestPoint
  • django.contrib.postgres.constraints.ExclusionConstraint.violation_error_code
  • choices args to form ChoiceField and model Field support Choices classes directly.
  • django.forms.URLField new assume_scheme arg
  • QuerySet.update_or_create and aupdate_or_create new create_defaults arg
  • new violation_error_code arg for BaseConstraint, CheckConstraint, and UniqueConstraint
  • new arg error_messages for django.core.paginator.Paginator.error_messages
  • new Signal.asend() and Signal.asend_robust() methods
  • The instance argument of the undocumented BaseModelFormSet.save_existing() method is renamed to obj.
  • The undocumented django.contrib.admin.helpers.checkbox is removed.
  • The undocumented Query.annotation_select_mask attribute is changed from a set of strings to an ordered list of strings.
  • Passing positional arguments name and violation_error_message to BaseConstraint is deprecated in favor of keyword-only arguments. (Let's make them keyword-only in the stubs in 5.0.)
  • request is added to the signature of ModelAdmin.lookup_allowed(). Support for ModelAdmin subclasses that do not accept this argument is deprecated.
  • The get_joining_columns() method of ForeignObject and ForeignObjectRel is deprecated. Starting with Django 6.0, django.db.models.sql.datastructures.Join will no longer fallback to get_joining_columns(). Subclasses should implement get_joining_fields() instead.
  • The undocumented django.utils.baseconv module is removed.
  • The undocumented django.utils.datetime_safe module is removed.
  • The extra_tests argument for DiscoverRunner.build_suite() and DiscoverRunner.run_tests() is removed.
  • The USE_L10N setting is removed.
  • Support for pytz timezones is removed.
  • The is_dst argument is removed from:
    • QuerySet.datetimes()
    • django.utils.timezone.make_aware()
    • django.db.models.functions.Trunc()
    • django.db.models.functions.TruncSecond()
    • django.db.models.functions.TruncMinute()
    • django.db.models.functions.TruncHour()
    • django.db.models.functions.TruncDay()
    • django.db.models.functions.TruncWeek()
    • django.db.models.functions.TruncMonth()
    • django.db.models.functions.TruncQuarter()
    • django.db.models.functions.TruncYear()
  • The django.contrib.gis.admin.GeoModelAdmin and OSMGeoAdmin classes are removed.
  • [ ]The undocumented BaseForm._html_output() method is removed.
  • The ability to return a str, rather than a SafeString, when rendering an ErrorDict and ErrorList is removed.
  • The SitemapIndexItem.__str__() method is removed.
  • The name argument of django.utils.functional.cached_property() is removed.
  • The opclasses argument of django.contrib.postgres.constraints.ExclusionConstraint is removed.
  • The undocumented ability to pass errors=None to SimpleTestCase.assertFormError() and assertFormsetError() is removed.
  • django.contrib.sessions.serializers.PickleSerializer is removed.
  • created=True is required in the signature of RemoteUserBackend.configure_user() subclasses.
  • Support for logging out via GET requests in the django.contrib.auth.views.LogoutView and django.contrib.auth.views.logout_then_login() is removed.
  • The django.utils.timezone.utc alias to datetime.timezone.utc is removed.
  • Passing a response object and a form/formset name to SimpleTestCase.assertFormError() and assertFormSetError() is no longer allowed.
  • The django.contrib.gis.admin.OpenLayersWidget is removed.
  • The django.contrib.auth.hashers.CryptPasswordHasher is removed.
  • Passing nulls_first=False or nulls_last=False to Expression.asc() and Expression.desc() methods, and the OrderBy expression is no longer allowed.
@adamchainz
Copy link
Contributor Author

I hope that if we have such a list we can run through them after 5.0 is released, rather than have small issues trickle in as users discover what has been missed.

@intgr
Copy link
Collaborator

intgr commented May 13, 2023

Agreed, this is helpful, thanks!

I think it would be more urgent to compile such a list for Django 4.2 (and we also probably missed some stuff in 4.1 and older even)

@adamchainz
Copy link
Contributor Author

I did this one first because it's easier, since I didn't need to find related issues here...

@bigfootjon
Copy link
Contributor

bigfootjon commented Sep 23, 2023

More changes since @adamchainz 's original message:

(Collapsed original list that is now outdated)
  • django.db.models.GeneratedField
  • django.contrib.admin.AdminSite.get_model_admin
  • django.contrib.admin.ModelAdmin.list_display now supports boolean attribute
  • django.contrib.auth.aauthenticate,aget_user,alogin,alogout,aupdate_session_auth_hash
  • django.contrib.auth.hashers.acheck_password
  • django.contrib.gis.GEOSGeometry.equals_identical
  • django.contrib.messages.MessagesTestMixin.assertMessages
  • Model.save now supports tuples passed to force_insert
  • UniqueConstraint.nulls_distinct
  • aget_object_or_404 and aget_list_or_404
  • aprefetch_related_objects
  • Client and AsyncClient have asession,alogin,aforce_login,alogout
  • AsyncClient now has follow parameter
  • StepValueValidator now has offset parameter
  • DatabaseFeatures.supports_expression_defaults,supports_default_keyword_in_insert,supports_default_keyword_in_bulk_insert
  • django.contrib.sitemaps.ping_google removed
  • QuerySet.update_or_create now has create_defaults (if a model has that field name it now uses create_defaults__exact
  • AlreadyRegistered,NotRegistered moved: django.contrib.admin.{sites,exceptions}
  • DjangoDivFormRenderer,Jinja2DivFormRenderer deprecated
  • ForeignObject.get_reverse_joining_columns deprecated
  • format_html called without args or kwargs is deprecated
  • DatabaseOperations.field_cast_sql deprecated
  • django.db.models.enums.ChoicesMeta renamed to ChoicesType
  • Prefetch.get_current_queryset deprecated
  • USE_DEPRECATED_PYTZ removed
  • CSRF_COOKIE_MASKED removed

I think I got everything, I'll try and tackle everything in the list I just made first since I can click the checkboxes.

Question for maintainers, how big of a PR should I make? Should each line item here be its own commit in one massive PR? How should we handle the version bumps in a separate PR?

@adamchainz
Copy link
Contributor Author

I prefer small PRs that can be easily reviewed, each with a link to the relevant commit/source. Happy if they group some related features but not too large.

I’m not sure when we’d aim to support 5.0. It would be more productive right now to whittle down the outstanding todo list per the contributing guide.

@bigfootjon
Copy link
Contributor

I just put up my first PR against this issue: #1741

For anyone else working on this, I found the blame view of the release notes on GitHub to be really helpful in tracking down the exact commit for a change: https://github.com/django/django/blame/main/docs/releases/5.0.txt

I'm about to go on a work trip for a few days so I won't be terribly responsive, but I wanted to get the first one of these going to make sure I'm doing everything right before I burn through more of the changes. Hopefully this PR isn't too far off base!

@intgr
Copy link
Collaborator

intgr commented Dec 6, 2023

Since 5.0 was officially released, I opened PR #1859 to update to it in our CI. (UPDATE: Merged now)

Also generated a separate stubtest allowlist for Django 5.0:

https://github.com/typeddjango/django-stubs/blob/master/scripts/stubtest/allowlist_todo_django50.txt

@intgr intgr pinned this issue Dec 7, 2023
@intgr intgr added help wanted Extra attention is needed good first issue Good for newcomers labels Dec 7, 2023
@Skorpyon
Copy link
Contributor

Holy thing. Looks like giant work.
db_default already affected me.

(venv) ➜  backend git:(main) ✗ mypy server
server/apps/main/models.py:25: error: Unexpected keyword argument "db_default" for "CharField"; did you mean "default"?  [call-arg]
Found 1 error in 1 file (checked 25 source files)

@intgr
Copy link
Collaborator

intgr commented Dec 11, 2023

Holy thing. Looks like giant work.

Yep. To repeat just in case: if someone's interested in contributing, please keep PRs small and focused on one topic.

@Skorpyon
Copy link
Contributor

please keep PRs small and focused on one topic

If talk about db_default at first look it simple:

class CharField(Field[_ST, _GT]):
    def __init__(
        self,
        ...
        db_default: Any = ...,
        ...
    ) -> None: ...

but I not understand how split .pyi versions between Django <5 and >=5
May you advice how django-stubs control Django version's features?

@intgr
Copy link
Collaborator

intgr commented Dec 13, 2023

If talk about db_default at first look it simple:

Great! 🎉

but I not understand how split .pyi versions between Django <5 and >=5
May you advice how django-stubs control Django version's features?

Don't worry about that. When there are differences between Django versions, django-stubs tracks the latest Django version (discussion here: #1095 (comment)).

@christianbundy
Copy link
Contributor

Do we have a sense for which of these TODOs are release blockers? Right now django-stubs is my only dependency blocking a Django 5.0 upgrade, so I'm interested to know what the next steps are to add enough compatibility.

@Viicos
Copy link
Contributor

Viicos commented Feb 14, 2024

I will have some time this week to work on the 5.0 changes

@intgr
Copy link
Collaborator

intgr commented Feb 14, 2024

Do we have a sense for which of these TODOs are release blockers?

I wouldn't consider any of them release blockers. No reason to delay improvements that are ready now, because everything is not yet perfect. But of course additional updates would be great to have.

But the priority for the release should be on getting open PRs reviewed and merged (ones that are close to being ready -- ignore the older messy ones).

The real reason for the lack of releases is that nobody has stepped up to do the release. Usually I was the one handling releases and reviewing PRs that fell through the cracks. But I had a long vacation and after that haven't found the right combination of time and motivation to push the next release forward. In retrospect I should have been more explicit about communicating my absence. But I didn't expect it to take this long.

If someone (preferably a current maintainer) is interested in handling the release, I'd be happy to instruct and help. But if not, I will get to it, but don't want to make promises yet.

Right now django-stubs is my only dependency blocking a Django 5.0 upgrade

Don't let that block your upgrade. django-stubs 4.2.7 works fine with Django 5.0 too, I've been using it myself. Any new or changed Django APIs may give type errors, but those can be solved with # type: ignore suppression until django-stubs catches up.

@JaeHyuckSa
Copy link
Contributor

We've merged lots of 5.0 PRs, but haven't kept these checklists up to date.

How do you think we should handle this checklist maintenance?

@sobolevn Is it viable to grant privileges to frequent contributors like q0w and ngnpope such that they can edit the checklists themselves?

@sobolevn Could you give me permission to update the checklist temporarily? I need it because I got confused checking while I was working on it.

@intgr
Copy link
Collaborator

intgr commented May 9, 2024

@saJaeHyukc Feel free to copy & paste the whole checklist to a new comment, and I will edit the previous comment to collapse it.

Here's the Markdown content of the last checklist: https://gist.github.com/intgr/126c9e366170e671e1bc6d12a2bc575a

@JaeHyuckSa
Copy link
Contributor

JaeHyuckSa commented May 11, 2024

This is a list created by @sudosubin.

This is the current list of tasks I have organized manually. It may be missing some from version 5.0, or include changes from version 4.2.

I think allowlist_todo_django50.txt can also help fill in the missing changes for version 5.0.

Django 4.2.8 (compare, release notes)

Django 5.0 (compare, release notes)

django.conf
  • django.conf.__init__
    • django.conf.USE_DEPRECATED_PYTZ_DEPRECATED_MSG was removed
    • django.conf.USE_L10N_DEPRECATED_MSG was removed
    • django.conf.CSRF_COOKIE_MASKED_DEPRECATED_MSG was removed
    • django.conf.FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG was added 5.0: Update django.conf #2008
  • django.conf.global_settings
django.contrib
django.core
django.db
django.dispatch
django.forms
django.http
django.middleware
  • django.middleware.locale
    • django.middleware.locale.LocaleMiddleware.get_fallback_language was removed
django.shortcuts
django.template, django.templatetags
django.test
django.utils
django.views

Django 5.0.1 (compare, release notes)

Django 5.0.2 (compare, release notes)

  • django.db.models.sql.query
    • django.db.models.sql.query.get_child_with_renamed_prefix's child argument was changed

Django 5.0.3 (compare, release notes)

Django 5.0.4 (compare, release notes)

No interface changes.

Django 5.0.5 e696331 (compare, release notes)

No interface changes.

Django 5.0.6 (compare, release notes)

No interface changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Development

No branches or pull requests

8 participants