Skip to content

Commit

Permalink
django 4.0支持
Browse files Browse the repository at this point in the history
  • Loading branch information
liangliangyy committed Feb 23, 2022
1 parent 030108f commit a78bc4d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
from django.conf.urls import url
from django.urls import include, re_path
from django.urls import path

from . import views
from .forms import LoginForm

app_name = "accounts"

urlpatterns = [url(r'^login/$',
urlpatterns = [re_path(r'^login/$',
views.LoginView.as_view(success_url='/'),
name='login',
kwargs={'authentication_form': LoginForm}),
url(r'^register/$',
re_path(r'^register/$',
views.RegisterView.as_view(success_url="/"),
name='register'),
url(r'^logout/$',
re_path(r'^logout/$',
views.LogoutView.as_view(),
name='logout'),
path(r'account/result.html',
views.account_result,
name='result'),
url(r'^forget_password/$',
re_path(r'^forget_password/$',
views.ForgetPasswordView.as_view(),
name='forget_password'),
url(r'^forget_password_code/$',
re_path(r'^forget_password_code/$',
views.ForgetPasswordEmailCode.as_view(),
name='forget_password_code'),
]
4 changes: 2 additions & 2 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from django.shortcuts import render
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.http import is_safe_url
from django.utils.http import url_has_allowed_host_and_scheme
from django.views import View
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
Expand Down Expand Up @@ -131,7 +131,7 @@ def form_valid(self, form):
def get_success_url(self):

redirect_to = self.request.POST.get(self.redirect_field_name)
if not is_safe_url(
if not url_has_allowed_host_and_scheme(
url=redirect_to, allowed_hosts=[
self.request.get_host()]):
redirect_to = self.success_url
Expand Down
2 changes: 1 addition & 1 deletion blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.auth import get_user_model
from django.urls import reverse
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

# Register your models here.
from .models import Article
Expand Down
4 changes: 2 additions & 2 deletions djangoblog/blog_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

logger = logging.getLogger(__name__)

oauth_user_login_signal = django.dispatch.Signal(providing_args=['id'])
oauth_user_login_signal = django.dispatch.Signal(['id'])
send_email_signal = django.dispatch.Signal(
providing_args=['emailto', 'title', 'content'])
['emailto', 'title', 'content'])


@receiver(send_email_signal)
Expand Down
6 changes: 3 additions & 3 deletions djangoblog/elasticsearch_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from elasticsearch_dsl import Q
from haystack.backends import BaseEngine, BaseSearchBackend, BaseSearchQuery, log_query
from haystack.models import SearchResult
Expand Down Expand Up @@ -98,9 +98,9 @@ def search(self, query_string, **kwargs):
class ElasticSearchQuery(BaseSearchQuery):
def _convert_datetime(self, date):
if hasattr(date, 'hour'):
return force_text(date.strftime('%Y%m%d%H%M%S'))
return force_str(date.strftime('%Y%m%d%H%M%S'))
else:
return force_text(date.strftime('%Y%m%d000000'))
return force_str(date.strftime('%Y%m%d000000'))

def clean(self, query_fragment):
"""
Expand Down
6 changes: 3 additions & 3 deletions djangoblog/logentryadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION
from django.contrib.contenttypes.models import ContentType
from django.urls import reverse, NoReverseMatch
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.translation import pgettext_lazy, ugettext_lazy as _
from django.utils.translation import pgettext_lazy, gettext_lazy as _

action_names = {
ADDITION: pgettext_lazy('logentry_admin:action_type', 'Addition'),
Expand Down Expand Up @@ -96,7 +96,7 @@ def object_link(self, obj):

def user_link(self, obj):
content_type = ContentType.objects.get_for_model(type(obj.user))
user_link = escape(force_text(obj.user))
user_link = escape(force_str(obj.user))
try:
# try returning an actual link instead of object repr string
url = reverse(
Expand Down
26 changes: 13 additions & 13 deletions djangoblog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls import url
from django.urls import include, re_path
from django.conf.urls.static import static
from django.contrib.sitemaps.views import sitemap
from django.urls import include
Expand All @@ -36,19 +36,19 @@
handler500 = 'blog.views.server_error_view'
handle403 = 'blog.views.permission_denied_view'
urlpatterns = [
url(r'^admin/', admin_site.urls),
url(r'', include('blog.urls', namespace='blog')),
url(r'mdeditor/', include('mdeditor.urls')),
url(r'', include('comments.urls', namespace='comment')),
url(r'', include('accounts.urls', namespace='account')),
url(r'', include('oauth.urls', namespace='oauth')),
url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
re_path(r'^admin/', admin_site.urls),
re_path(r'', include('blog.urls', namespace='blog')),
re_path(r'mdeditor/', include('mdeditor.urls')),
re_path(r'', include('comments.urls', namespace='comment')),
re_path(r'', include('accounts.urls', namespace='account')),
re_path(r'', include('oauth.urls', namespace='oauth')),
re_path(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
url(r'^feed/$', DjangoBlogFeed()),
url(r'^rss/$', DjangoBlogFeed()),
url(r'^search', include('haystack.urls'), name='search'),
url(r'', include('servermanager.urls', namespace='servermanager')),
url(r'', include('owntracks.urls', namespace='owntracks'))
re_path(r'^feed/$', DjangoBlogFeed()),
re_path(r'^rss/$', DjangoBlogFeed()),
re_path(r'^search', include('haystack.urls'), name='search'),
re_path(r'', include('servermanager.urls', namespace='servermanager')),
re_path(r'', include('owntracks.urls', namespace='owntracks'))
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL,
Expand Down
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
coverage==6.2
bleach==4.1.0
Django==3.2.9
Django==4.0.2
django-compressor==3.1
django-haystack==3.1.1
django-ipware==4.0.2
django-mdeditor==0.1.18
django-uuslug==1.2.0
django-mdeditor==0.1.20
django-uuslug==2.0.0
elasticsearch==7.16.1
elasticsearch-dsl==7.4.0
gevent==21.12.0
jieba==0.42.1
jsonpickle==2.0.0
Markdown==3.3.6
mysqlclient==2.1.0
Pillow==8.4.0
Pygments==2.10.0
Pillow==9.0.1
Pygments==2.11.2
python-logstash==0.4.6
python-memcached==1.59
python-slugify==5.0.2
python-slugify==6.1.0
pytz==2021.3
raven==6.10.0
requests==2.26.0
urllib3==1.26.7
WeRoBot==1.13.1
Whoosh==2.7.4
user-agents==2.2.0
user-agents==2.2.0

0 comments on commit a78bc4d

Please sign in to comment.