diff --git a/.travis.yml b/.travis.yml index e5c4bf0..c8bdd2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,12 @@ language: python python: - - "2.7" - - "3.4" + - "3.9" + - "3.10" + - "3.11" env: - - DJANGO_VERSION=1.7.11 - - DJANGO_VERSION=1.8.10 - - DJANGO_VERSION=1.9.4 + - DJANGO_VERSION=3.2.23 + - DJANGO_VERSION=4.1.13 + - DJANGO_VERSION=4.2.8 script: "python manage.py test batchform" install: - pip install Django==$DJANGO_VERSION --quiet --use-mirrors diff --git a/batchform/forms.py b/batchform/forms.py index 344a6be..ddefa66 100644 --- a/batchform/forms.py +++ b/batchform/forms.py @@ -6,7 +6,7 @@ from django import forms from django.forms import formsets -from django.utils.encoding import force_text +from django.utils.encoding import force_str from . import parsers from .parsers import csv as csv_parsers @@ -40,7 +40,7 @@ def clean_file(self): raise forms.ValidationError( "No parser could read the file. Tried with parsers %s." % - (", " % (force_text(p) for p in available_parsers))) + (", " % (force_str(p) for p in available_parsers))) class LineFormSet(formsets.BaseFormSet): diff --git a/batchform/templates/batchform/lines_form.html b/batchform/templates/batchform/lines_form.html index d089903..552d5ea 100644 --- a/batchform/templates/batchform/lines_form.html +++ b/batchform/templates/batchform/lines_form.html @@ -1,5 +1,5 @@ {% extends "batchform/base.html" %} -{% load i18n staticfiles %} +{% load i18n static %} {% block css %} {{ block.super }} diff --git a/batchform/tests/test_views.py b/batchform/tests/test_views.py index a875815..ba1bfb6 100644 --- a/batchform/tests/test_views.py +++ b/batchform/tests/test_views.py @@ -9,11 +9,18 @@ from django import forms from django.test import TestCase +import django.contrib.messages.storage.cookie as cookie_storage data_dir = os.path.join(os.path.dirname(__file__), 'data') +def decode_cookie_messages(cookie): + """Decode a cookie encoded by CookieStorage + """ + return cookie_storage.CookieStorage(request=None)._decode(cookie) + + class BaseTestCase(TestCase): urls = 'dev.urls' @@ -62,7 +69,7 @@ def test_lines_form(self): }) self.assertRedirects(response, '/') - self.assertIn("3 lines", response.cookies['messages'].value) + self.assertIn("3 lines", decode_cookie_messages(response.cookies['messages'].value)[0].message) def test_incomplete_form(self): response = self.client.post('/', { @@ -107,4 +114,4 @@ def test_lines_form_with_deleted(self): }) self.assertRedirects(response, '/') - self.assertIn("2 lines", response.cookies['messages'].value) + self.assertIn("2 lines", decode_cookie_messages(response.cookies['messages'].value)[0].message) diff --git a/dev/settings.py b/dev/settings.py index d127197..78809a5 100644 --- a/dev/settings.py +++ b/dev/settings.py @@ -6,6 +6,7 @@ import os.path ROOT_DIR = os.path.abspath(os.path.dirname(__file__)) +BASE_DIR = os.path.abspath(os.path.dirname(ROOT_DIR)) DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -90,7 +91,7 @@ # 'django.template.loaders.eggs.Loader', ) -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -105,12 +106,13 @@ # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'dev.wsgi.application' -TEMPLATE_DIRS = ( - # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. - os.path.join(ROOT_DIR, 'templates'), -) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + } +] INSTALLED_APPS = ( 'django.contrib.auth', diff --git a/dev/site/templates/base.html b/dev/site/templates/base.html index f500fb4..30cd1c0 100644 --- a/dev/site/templates/base.html +++ b/dev/site/templates/base.html @@ -1,4 +1,4 @@ -{% load staticfiles %} +{% load static %}