Skip to content

Commit

Permalink
fix: Django 4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Sep 11, 2023
1 parent affcdfc commit b5a9005
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion example/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from django.utils.translation import ugettext, ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.admin import UserAdmin

from .models import *
Expand Down
4 changes: 2 additions & 2 deletions example/accounts/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.models import AbstractUser
from django.contrib.auth import get_user_model
from django.conf import settings
Expand All @@ -22,7 +22,7 @@ class User(AbstractUser):

def __str__(self):
return f'{self.first_name} {self.last_name}'

class Meta:
ordering = ['username']
verbose_name_plural = _("Users")
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
django>=2.0,<4.0
django>=3.2.20,<5.0
git+https://github.com/UniversitaDellaCalabria/django-auto-serializer@dev
django-filter
django-nested-admin>=3.3.2
django-taggit<=1.5.1
django-taggit-serializer
django-taggit
pillow>=7.2.0
python-magic>=0.4.18
pymongo>=4.0
django-rest-framework
djangorestframework
uritemplate
pyyaml
pydantic
Expand Down
4 changes: 2 additions & 2 deletions src/cms/contexts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def detect_user_language(request):
current = request.session.get(f'_unicms_website_{website.pk}_lang', website_lang) # current session website language
else:
# if there is a choosen language in session, overwrite current
current = request.session.get(translation.LANGUAGE_SESSION_KEY, req_lang) # current session language
current = request.session.get('_unicms_lang', req_lang) # current session language

# if user changes language in URL overwrite current
lang = request.GET.get('lang', current)
Expand All @@ -63,7 +63,7 @@ def detect_user_language(request):
if website_lang:
request.session[f'_unicms_website_{website.pk}_lang'] = lang
else:
request.session[translation.LANGUAGE_SESSION_KEY] = lang
request.session['_unicms_lang'] = lang

# return
return lang
Expand Down
2 changes: 1 addition & 1 deletion src/cms/medias/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from rest_framework import serializers

from taggit_serializer.serializers import (TagListSerializerField,
from taggit.serializers import (TagListSerializerField,
TaggitSerializer)

from . models import Media, MediaCollection, MediaCollectionItem
Expand Down
4 changes: 2 additions & 2 deletions src/cms/pages/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class PageAdmin(AbstractPreviewableAdmin, nested_admin.NestedModelAdmin):
PageMediaCollectionInline,
PageLinkInline,
PageHeadingInline)
actions = AbstractPreviewableAdmin.actions + [make_page_draft,
update_template]
actions = AbstractPreviewableAdmin.actions + (make_page_draft,
update_template)

raw_id_fields = ['webpath', 'base_template']

Expand Down
2 changes: 1 addition & 1 deletion src/cms/pages/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class PagesConfig(AppConfig):
Expand Down
2 changes: 1 addition & 1 deletion src/cms/pages/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from rest_framework import serializers

from taggit_serializer.serializers import (TagListSerializerField,
from taggit.serializers import (TagListSerializerField,
TaggitSerializer)

from . models import *
Expand Down
2 changes: 1 addition & 1 deletion src/cms/publications/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class PublicationsConfig(AppConfig):
Expand Down
2 changes: 1 addition & 1 deletion src/cms/publications/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from rest_framework import serializers

from taggit_serializer.serializers import (TagListSerializerField,
from taggit.serializers import (TagListSerializerField,
TaggitSerializer)

from . models import *
Expand Down

0 comments on commit b5a9005

Please sign in to comment.