Skip to content

Commit a78bc4d

Browse files
committed
django 4.0支持
1 parent 030108f commit a78bc4d

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

accounts/urls.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
from django.conf.urls import url
1+
from django.urls import include, re_path
22
from django.urls import path
33

44
from . import views
55
from .forms import LoginForm
66

77
app_name = "accounts"
88

9-
urlpatterns = [url(r'^login/$',
9+
urlpatterns = [re_path(r'^login/$',
1010
views.LoginView.as_view(success_url='/'),
1111
name='login',
1212
kwargs={'authentication_form': LoginForm}),
13-
url(r'^register/$',
13+
re_path(r'^register/$',
1414
views.RegisterView.as_view(success_url="/"),
1515
name='register'),
16-
url(r'^logout/$',
16+
re_path(r'^logout/$',
1717
views.LogoutView.as_view(),
1818
name='logout'),
1919
path(r'account/result.html',
2020
views.account_result,
2121
name='result'),
22-
url(r'^forget_password/$',
22+
re_path(r'^forget_password/$',
2323
views.ForgetPasswordView.as_view(),
2424
name='forget_password'),
25-
url(r'^forget_password_code/$',
25+
re_path(r'^forget_password_code/$',
2626
views.ForgetPasswordEmailCode.as_view(),
2727
name='forget_password_code'),
2828
]

accounts/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from django.shortcuts import render
1515
from django.urls import reverse
1616
from django.utils.decorators import method_decorator
17-
from django.utils.http import is_safe_url
17+
from django.utils.http import url_has_allowed_host_and_scheme
1818
from django.views import View
1919
from django.views.decorators.cache import never_cache
2020
from django.views.decorators.csrf import csrf_protect
@@ -131,7 +131,7 @@ def form_valid(self, form):
131131
def get_success_url(self):
132132

133133
redirect_to = self.request.POST.get(self.redirect_field_name)
134-
if not is_safe_url(
134+
if not url_has_allowed_host_and_scheme(
135135
url=redirect_to, allowed_hosts=[
136136
self.request.get_host()]):
137137
redirect_to = self.success_url

blog/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.contrib.auth import get_user_model
44
from django.urls import reverse
55
from django.utils.html import format_html
6-
from django.utils.translation import ugettext_lazy as _
6+
from django.utils.translation import gettext_lazy as _
77

88
# Register your models here.
99
from .models import Article

djangoblog/blog_signals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
logger = logging.getLogger(__name__)
2020

21-
oauth_user_login_signal = django.dispatch.Signal(providing_args=['id'])
21+
oauth_user_login_signal = django.dispatch.Signal(['id'])
2222
send_email_signal = django.dispatch.Signal(
23-
providing_args=['emailto', 'title', 'content'])
23+
['emailto', 'title', 'content'])
2424

2525

2626
@receiver(send_email_signal)

djangoblog/elasticsearch_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.utils.encoding import force_text
1+
from django.utils.encoding import force_str
22
from elasticsearch_dsl import Q
33
from haystack.backends import BaseEngine, BaseSearchBackend, BaseSearchQuery, log_query
44
from haystack.models import SearchResult
@@ -98,9 +98,9 @@ def search(self, query_string, **kwargs):
9898
class ElasticSearchQuery(BaseSearchQuery):
9999
def _convert_datetime(self, date):
100100
if hasattr(date, 'hour'):
101-
return force_text(date.strftime('%Y%m%d%H%M%S'))
101+
return force_str(date.strftime('%Y%m%d%H%M%S'))
102102
else:
103-
return force_text(date.strftime('%Y%m%d000000'))
103+
return force_str(date.strftime('%Y%m%d000000'))
104104

105105
def clean(self, query_fragment):
106106
"""

djangoblog/logentryadmin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION
33
from django.contrib.contenttypes.models import ContentType
44
from django.urls import reverse, NoReverseMatch
5-
from django.utils.encoding import force_text
5+
from django.utils.encoding import force_str
66
from django.utils.html import escape
77
from django.utils.safestring import mark_safe
8-
from django.utils.translation import pgettext_lazy, ugettext_lazy as _
8+
from django.utils.translation import pgettext_lazy, gettext_lazy as _
99

1010
action_names = {
1111
ADDITION: pgettext_lazy('logentry_admin:action_type', 'Addition'),
@@ -96,7 +96,7 @@ def object_link(self, obj):
9696

9797
def user_link(self, obj):
9898
content_type = ContentType.objects.get_for_model(type(obj.user))
99-
user_link = escape(force_text(obj.user))
99+
user_link = escape(force_str(obj.user))
100100
try:
101101
# try returning an actual link instead of object repr string
102102
url = reverse(

djangoblog/urls.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
1515
"""
1616
from django.conf import settings
17-
from django.conf.urls import url
17+
from django.urls import include, re_path
1818
from django.conf.urls.static import static
1919
from django.contrib.sitemaps.views import sitemap
2020
from django.urls import include
@@ -36,19 +36,19 @@
3636
handler500 = 'blog.views.server_error_view'
3737
handle403 = 'blog.views.permission_denied_view'
3838
urlpatterns = [
39-
url(r'^admin/', admin_site.urls),
40-
url(r'', include('blog.urls', namespace='blog')),
41-
url(r'mdeditor/', include('mdeditor.urls')),
42-
url(r'', include('comments.urls', namespace='comment')),
43-
url(r'', include('accounts.urls', namespace='account')),
44-
url(r'', include('oauth.urls', namespace='oauth')),
45-
url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
39+
re_path(r'^admin/', admin_site.urls),
40+
re_path(r'', include('blog.urls', namespace='blog')),
41+
re_path(r'mdeditor/', include('mdeditor.urls')),
42+
re_path(r'', include('comments.urls', namespace='comment')),
43+
re_path(r'', include('accounts.urls', namespace='account')),
44+
re_path(r'', include('oauth.urls', namespace='oauth')),
45+
re_path(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
4646
name='django.contrib.sitemaps.views.sitemap'),
47-
url(r'^feed/$', DjangoBlogFeed()),
48-
url(r'^rss/$', DjangoBlogFeed()),
49-
url(r'^search', include('haystack.urls'), name='search'),
50-
url(r'', include('servermanager.urls', namespace='servermanager')),
51-
url(r'', include('owntracks.urls', namespace='owntracks'))
47+
re_path(r'^feed/$', DjangoBlogFeed()),
48+
re_path(r'^rss/$', DjangoBlogFeed()),
49+
re_path(r'^search', include('haystack.urls'), name='search'),
50+
re_path(r'', include('servermanager.urls', namespace='servermanager')),
51+
re_path(r'', include('owntracks.urls', namespace='owntracks'))
5252
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
5353
if settings.DEBUG:
5454
urlpatterns += static(settings.MEDIA_URL,

requirements.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
coverage==6.2
22
bleach==4.1.0
3-
Django==3.2.9
3+
Django==4.0.2
44
django-compressor==3.1
55
django-haystack==3.1.1
66
django-ipware==4.0.2
7-
django-mdeditor==0.1.18
8-
django-uuslug==1.2.0
7+
django-mdeditor==0.1.20
8+
django-uuslug==2.0.0
99
elasticsearch==7.16.1
1010
elasticsearch-dsl==7.4.0
1111
gevent==21.12.0
1212
jieba==0.42.1
1313
jsonpickle==2.0.0
1414
Markdown==3.3.6
1515
mysqlclient==2.1.0
16-
Pillow==8.4.0
17-
Pygments==2.10.0
16+
Pillow==9.0.1
17+
Pygments==2.11.2
1818
python-logstash==0.4.6
1919
python-memcached==1.59
20-
python-slugify==5.0.2
20+
python-slugify==6.1.0
2121
pytz==2021.3
2222
raven==6.10.0
2323
requests==2.26.0
2424
urllib3==1.26.7
2525
WeRoBot==1.13.1
2626
Whoosh==2.7.4
27-
user-agents==2.2.0
27+
user-agents==2.2.0

0 commit comments

Comments
 (0)