Skip to content

Commit 7d0b661

Browse files
committed
Use pathlib instead of legacy os.path
1 parent 6aa9f59 commit 7d0b661

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

adminsortable2/admin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import os
21
import json
2+
from pathlib import Path
33
from itertools import chain
44
from types import MethodType
55

6+
from django.conf import settings
67
from django.contrib import admin, messages
78
from django.contrib.contenttypes.forms import BaseGenericInlineFormSet
89
from django.contrib.contenttypes.models import ContentType
@@ -62,7 +63,7 @@ class SortableAdminBase:
6263
@property
6364
def media(self):
6465
css = {'all': ['adminsortable2/css/sortable.css']}
65-
js = ['adminsortable2/js/adminsortable2.min.js']
66+
js = ['adminsortable2/js/adminsortable2{}.js'.format('' if settings.DEBUG else '.min')]
6667
return super().media + widgets.Media(css=css, js=js)
6768

6869
def get_formset_kwargs(self, request, obj, inline, prefix):
@@ -95,9 +96,9 @@ def change_list_template(self):
9596
opts = self.model._meta
9697
app_label = opts.app_label
9798
return [
98-
os.path.join('adminsortable2', app_label, opts.model_name, 'change_list.html'),
99-
os.path.join('adminsortable2', app_label, 'change_list.html'),
100-
'adminsortable2/change_list.html'
99+
Path('adminsortable2') / Path(app_label) / Path(opts.model_name) / Path('change_list.html'),
100+
Path('adminsortable2') / Path(app_label) / Path('change_list.html'),
101+
Path('adminsortable2/change_list.html'),
101102
]
102103

103104
def __init__(self, model, admin_site):

0 commit comments

Comments
 (0)