From: Radek Czajka Date: Wed, 25 Oct 2023 10:41:23 +0000 (+0200) Subject: fix X-Git-Tag: 2.2.9 X-Git-Url: https://git.mdrn.pl/django-pagination.git/commitdiff_plain/40b8806ceab23838d51394a0876a5d3153db5611 fix --- diff --git a/fnp_django_pagination/__init__.py b/fnp_django_pagination/__init__.py index aa7b1e6..c6033e7 100644 --- a/fnp_django_pagination/__init__.py +++ b/fnp_django_pagination/__init__.py @@ -34,4 +34,4 @@ tools throughout a django application. """ -__version__ = (2, 2, 8, "final", 0) +__version__ = (2, 2, 9, "final", 0) diff --git a/fnp_django_pagination/templatetags/pagination_tags.py b/fnp_django_pagination/templatetags/pagination_tags.py index 12d8324..0845501 100644 --- a/fnp_django_pagination/templatetags/pagination_tags.py +++ b/fnp_django_pagination/templatetags/pagination_tags.py @@ -270,6 +270,15 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN): window=2, margin=0, current=11 ... 7 8 9 10 [11] """ + try: + window = int(window) + except ValueError: + window = Variable(window).resolve(context) + try: + margin = int(margin) + except ValueError: + margin = Variable(margin).resolve(context) + if window < 0: raise ValueError('Parameter "window" cannot be less than zero') if margin < 0: @@ -277,14 +286,6 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN): try: paginator = context['paginator'] page_obj = context['page_obj'] - try: - window = int(window) - except ValueError: - window = Variable(window).resolve(context) - try: - margin = int(margin) - except ValueError: - margin = Variable(margin).resolve(context) page_suffix = context.get('page_suffix', '') page_range = list(paginator.page_range) # Calculate the record range in the current page for display.