adamchainz / django-upgrade

Automatically upgrade your Django projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support removal of `django.core.urlresolvers` on Django 2.0

bityob opened this issue · comments

Description

Example -

-from django.core.urlresolvers import reverse
+from django.urls import reverse

The django.core.urlresolvers module is removed in favor of its new location, django.urls.

Source: https://docs.djangoproject.com/en/4.2/releases/2.0/

Also ran into this when upgrading, which django-upgrade missed :)

Django 2.0 was released nearly six years ago. At this point, I don’t really care to implement a fixer for the handful of projects that will use it, but would review a PR.

That's fair enough - to be clear that wasn't a criticism, the tool has been extremely helpful.

That's fair enough - to be clear that wasn't a criticism, the tool has been extremely helpful.

Ye that was not really clear from your previous comment which felt a bit passive-aggressive in my opinion, thanks for the clarification.

I'll submit a PR for review later today to support this, I think this can be easily done following changes made in #295

I can only apologise for coming across that way. I appreciate all the work you have done to help simplify these upgrades for the community.

I did bump into another couple of things that it could have auto-changed, for example the attribute naming in the ForeignKey class:

  • Switch ForeignKey.rel to ForeignKey.remote_field

  • Switch ForeignKey.rel.to to ForeignKey.remote_field.model

But likewise, as @adamchainz pointed out, it might not be worth adding these to the tool for such an old Django version.