Skip to content

Commit

Permalink
Merge branch 'main' into docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
ebertti authored Aug 28, 2024
2 parents e8d64ba + 11f98df commit 1d60805
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
1 change: 1 addition & 0 deletions easy/admin/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

HttpRequest: django.http.HttpRequest


class MixinEasyViews(object):

def _get_info(self):
Expand Down
31 changes: 8 additions & 23 deletions easy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,15 @@ def get_django_filter(django_filter: str, load: str = 'django') -> Callable:
Raises:
Exception: If the specified Django filter or templatetag library does not exist.
"""
if django.VERSION < (1, 9):
from django.template.base import get_library
if load and load != 'django':
library = get_library(load)
else:
library_path = 'django.template.defaultfilters'
if django.VERSION > (1, 8):
from django.template.base import import_library
library = import_library(library_path)
else:
from django.template import import_library
library = import_library(library_path)

from django.template.backends.django import get_installed_libraries
from django.template.library import import_library
libraries = get_installed_libraries()
if load and not load == 'django':
library_path = libraries.get(load)
if not library_path:
raise Exception('templatetag "{}" is not registered'.format(load))
else:
from django.template.backends.django import get_installed_libraries
from django.template.library import import_library
libraries = get_installed_libraries()
if load and load != 'django':
library_path = libraries.get(load)
if not library_path:
raise Exception(f'templatetag "{load}" is not registered')
else:
library_path = 'django.template.defaultfilters'
library_path = 'django.template.defaultfilters'

library = import_library(library_path)
filter_method = library.filters.get(django_filter)
Expand Down Expand Up @@ -108,7 +94,6 @@ def call_or_get(obj: object, attr: Union[str, Callable[[object], Any]], default:

return ret


def cache_method_key(model: Model, method_name: str) -> str:
"""
Generates a cache key for a method of a model instance.
Expand Down

0 comments on commit 1d60805

Please sign in to comment.