diff --git a/later42/settings.py b/later42/settings.py index 00ae201..ea96a1d 100644 --- a/later42/settings.py +++ b/later42/settings.py @@ -20,7 +20,8 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = os.getenv('SECRET', 'django-insecure-c%g@wujt4dco#e%k-!25o3)0%t+wm5=k%l(m!kk^p_g%kknod!') +SECRET_KEY = os.getenv( + 'SECRET', 'django-insecure-c%g@wujt4dco#e%k-!25o3)0%t+wm5=k%l(m!kk^p_g%kknod!') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv('DEBUG', 'False') @@ -156,3 +157,5 @@ REST_FRAMEWORK = { 'rest_framework.permissions.IsAuthenticated', ), } + +URLS_PER_PAGE = 20 diff --git a/later42/templates/archive.html b/later42/templates/archive.html index d8a7166..979ae89 100644 --- a/later42/templates/archive.html +++ b/later42/templates/archive.html @@ -1,6 +1,7 @@ {% extends 'base.html' %} {% block content %} +
{% if urls|length > 0 %} {% for url in urls %} @@ -23,8 +24,25 @@
{% endfor %} {% else %} -

У вас нет ссылок в архиве

-
{% endif %} +
+ {% endblock %} \ No newline at end of file diff --git a/later42/views/index.py b/later42/views/index.py index cd26d01..70eea5b 100644 --- a/later42/views/index.py +++ b/later42/views/index.py @@ -1,6 +1,8 @@ from multiprocessing import context from django.contrib.auth.decorators import login_required from django.shortcuts import render, redirect +from django.core.paginator import Paginator +from django.conf import settings from later42.models.urls import URL @@ -22,6 +24,9 @@ def archive(request, url_id=None): try: urls = URL.objects.filter( user=request.user, archived=True).order_by('-id') + paginator = Paginator(urls, settings.URLS_PER_PAGE) + page_number = request.GET.get('page') + urls = paginator.get_page(page_number) except: urls = [] context = {'urls': urls}