diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..06ba67c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,49 @@ +name: Django CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + django-version: ['3.2.*', '4.0.*', '4.1.*', '4.2.*', '5.0.*'] + exclude: + - django-version: '3.2.*' + python-version: '3.11' + - django-version: '3.2.*' + python-version: '3.12' + + - django-version: '4.0.*' + python-version: '3.11' + - django-version: '4.0.*' + python-version: '3.12' + + - django-version: '4.1.*' + python-version: '3.12' + + - django-version: '5.0.*' + python-version: '3.8' + - django-version: '5.0.*' + python-version: '3.9' + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install setuptools + pip install Django==${{ matrix.django-version }} + python setup.py install + pip install -r test_requirements.txt + + - name: Run tests + run: DJANGO_SETTINGS_MODULE=demoproject.demoproject.settings python setup.py test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e86ffd0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: python -python: - - 2.7 - - 3.3 - - 3.4 - - 3.5 -env: - - DJANGO_VERSION=1.9.* - - DJANGO_VERSION=1.8.* -install: - - pip install Django=="$DJANGO_VERSION" - - python setup.py install -script: - - if [[ $DJANGO_VERSION != 1.9.* || $TRAVIS_PYTHON_VERSION != 3.3 ]]; then python setup.py test; fi diff --git a/demoproject/demoproject/settings.py b/demoproject/demoproject/settings.py index a4e679a..8658ee2 100644 --- a/demoproject/demoproject/settings.py +++ b/demoproject/demoproject/settings.py @@ -3,7 +3,6 @@ import os DEBUG = True -TEMPLATE_DEBUG = DEBUG APPLICATION_DIR = os.path.dirname(globals()['__file__']) @@ -97,11 +96,37 @@ SECRET_KEY = 'sq)9^f#mf444c(#om$zpo0v!%y=%pqem*9s_qav93fwr_&x40u' # List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - 'django.template.loaders.eggs.Loader', -) +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [os.path.join(APPLICATION_DIR, "templates")], + "OPTIONS": { + "debug": DEBUG, + "loaders": [ + ( + "django.template.loaders.cached.Loader", + [ + "django.template.loaders.filesystem.Loader", + "django.template.loaders.app_directories.Loader", + "admin_tools.template_loaders.Loader", + ], + ), + ], + "context_processors": [ + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + "django.template.context_processors.debug", + "django.template.context_processors.i18n", + "django.template.context_processors.media", + "django.template.context_processors.static", + "django.template.context_processors.csrf", + "django.template.context_processors.tz", + "django.template.context_processors.request", + ], + }, + } +] + MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', @@ -118,8 +143,6 @@ # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'demoproject.wsgi.application' -TEMPLATE_DIRS = (os.path.join(APPLICATION_DIR, 'templates'), ) - INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/demoproject/demoproject/urls.py b/demoproject/demoproject/urls.py index 53646f2..e7affbd 100644 --- a/demoproject/demoproject/urls.py +++ b/demoproject/demoproject/urls.py @@ -1,21 +1,21 @@ -from django.conf.urls import url +from django.urls import path from . import views urlpatterns = [ - url(r'^$', views.home, name='home'), - url(r'^piechart/', views.demo_piechart, name='demo_piechart'), - url(r'^linechart/', views.demo_linechart, name='demo_linechart'), - url(r'^linechart_without_date/', views.demo_linechart_without_date, name='demo_linechart_without_date'), - url(r'^linewithfocuschart/', views.demo_linewithfocuschart, name='demo_linewithfocuschart'), - url(r'^multibarchart/', views.demo_multibarchart, name='demo_multibarchart'), - url(r'^stackedareachart/', views.demo_stackedareachart, name='demo_stackedareachart'), - url(r'^multibarhorizontalchart/', views.demo_multibarhorizontalchart, name='demo_multibarhorizontalchart'), - url(r'^lineplusbarchart/', views.demo_lineplusbarchart, name='demo_lineplusbarchart'), - url(r'^cumulativelinechart/', views.demo_cumulativelinechart, name='demo_cumulativelinechart'), - url(r'^discretebarchart/', views.demo_discretebarchart, name='demo_discretebarchart'), - url(r'^discretebarchart_with_date/', views.demo_discretebarchart_with_date, name='demo_discretebarchart_date'), - url(r'^scatterchart/', views.demo_scatterchart, name='demo_scatterchart'), - url(r'^linechart_with_ampm/', views.demo_linechart_with_ampm, name='demo_linechart_with_ampm'), - # url(r'^demoproject/', include('demoproject.foo.urls')), + path('', views.home, name='home'), + path('piechart/', views.demo_piechart, name='demo_piechart'), + path('linechart/', views.demo_linechart, name='demo_linechart'), + path('linechart_without_date/', views.demo_linechart_without_date, name='demo_linechart_without_date'), + path('linewithfocuschart/', views.demo_linewithfocuschart, name='demo_linewithfocuschart'), + path('multibarchart/', views.demo_multibarchart, name='demo_multibarchart'), + path('stackedareachart/', views.demo_stackedareachart, name='demo_stackedareachart'), + path('multibarhorizontalchart/', views.demo_multibarhorizontalchart, name='demo_multibarhorizontalchart'), + path('lineplusbarchart/', views.demo_lineplusbarchart, name='demo_lineplusbarchart'), + path('cumulativelinechart/', views.demo_cumulativelinechart, name='demo_cumulativelinechart'), + path('discretebarchart/', views.demo_discretebarchart, name='demo_discretebarchart'), + path('discretebarchart_with_date/', views.demo_discretebarchart_with_date, name='demo_discretebarchart_date'), + path('scatterchart/', views.demo_scatterchart, name='demo_scatterchart'), + path('linechart_with_ampm/', views.demo_linechart_with_ampm, name='demo_linechart_with_ampm'), + # path('^demoproject/', include('demoproject.foo.urls')), ] diff --git a/demoproject/demoproject/views.py b/demoproject/demoproject/views.py index a3c00a5..b655e2d 100644 --- a/demoproject/demoproject/views.py +++ b/demoproject/demoproject/views.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from django.shortcuts import render_to_response +from django.shortcuts import render import random import datetime import time @@ -10,7 +10,7 @@ def home(request): """ home page """ - return render_to_response('home.html') + return render(request, 'home.html') def demo_piechart(request): @@ -42,7 +42,7 @@ def demo_piechart(request): 'jquery_on_ready': False, } } - return render_to_response('piechart.html', data) + return render(request, 'piechart.html', data) def demo_linechart(request): @@ -83,7 +83,7 @@ def demo_linechart(request): 'jquery_on_ready': False, } } - return render_to_response('linechart.html', data) + return render('linechart.html', data) def demo_linechart_without_date(request): @@ -110,7 +110,7 @@ def demo_linechart_without_date(request): 'jquery_on_ready': False, } } - return render_to_response('linechart.html', data) + return render(request, 'linechart.html', data) def demo_linewithfocuschart(request): @@ -151,7 +151,7 @@ def demo_linewithfocuschart(request): 'jquery_on_ready': True, } } - return render_to_response('linewithfocuschart.html', data) + return render(request, 'linewithfocuschart.html', data) def demo_multibarchart(request): @@ -215,7 +215,7 @@ def demo_multibarchart(request): 'jquery_on_ready': True, }, } - return render_to_response('multibarchart.html', data) + return render(request, 'multibarchart.html', data) def demo_stackedareachart(request): @@ -249,7 +249,7 @@ def demo_stackedareachart(request): 'jquery_on_ready': True, }, } - return render_to_response('stackedareachart.html', data) + return render(request, 'stackedareachart.html', data) def demo_multibarhorizontalchart(request): @@ -282,7 +282,7 @@ def demo_multibarhorizontalchart(request): 'jquery_on_ready': True, }, } - return render_to_response('multibarhorizontalchart.html', data) + return render(request, 'multibarhorizontalchart.html', data) def demo_lineplusbarchart(request): @@ -324,7 +324,7 @@ def demo_lineplusbarchart(request): 'focus_enable': True, }, } - return render_to_response('lineplusbarchart.html', data) + return render(request, 'lineplusbarchart.html', data) def demo_cumulativelinechart(request): @@ -363,7 +363,7 @@ def demo_cumulativelinechart(request): 'jquery_on_ready': True, }, } - return render_to_response('cumulativelinechart.html', data) + return render(request, 'cumulativelinechart.html', data) def demo_discretebarchart(request): @@ -390,7 +390,7 @@ def demo_discretebarchart(request): 'jquery_on_ready': True, }, } - return render_to_response('discretebarchart.html', data) + return render(request, 'discretebarchart.html', data) def demo_discretebarchart_with_date(request): @@ -421,7 +421,7 @@ def demo_discretebarchart_with_date(request): 'jquery_on_ready': True, }, } - return render_to_response('discretebarchart_with_date.html', data) + return render(request, 'discretebarchart_with_date.html', data) def demo_scatterchart(request): @@ -459,7 +459,7 @@ def demo_scatterchart(request): 'jquery_on_ready': True, }, } - return render_to_response('scatterchart.html', data) + return render(request, 'scatterchart.html', data) def demo_linechart_with_ampm(request): @@ -494,4 +494,4 @@ def demo_linechart_with_ampm(request): 'jquery_on_ready': True, } } - return render_to_response('linechart_with_ampm.html', data) + return render(request, 'linechart_with_ampm.html', data) diff --git a/nvd3_tests/testproject/settings.py b/nvd3_tests/testproject/settings.py index 107c6e5..eae586d 100644 --- a/nvd3_tests/testproject/settings.py +++ b/nvd3_tests/testproject/settings.py @@ -3,7 +3,6 @@ import os DEBUG = True -TEMPLATE_DEBUG = DEBUG APPLICATION_DIR = os.path.dirname(globals()['__file__']) @@ -90,11 +89,36 @@ SECRET_KEY = 'sq)9^f#mf444c(#om$zpo0v!%y=%pqem*9s_qav93fwr_&x40u' # List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - 'django.template.loaders.eggs.Loader', -) +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [os.path.join(APPLICATION_DIR, "templates")], + "OPTIONS": { + "debug": DEBUG, + "loaders": [ + ( + "django.template.loaders.cached.Loader", + [ + "django.template.loaders.filesystem.Loader", + "django.template.loaders.app_directories.Loader", + "admin_tools.template_loaders.Loader", + ], + ), + ], + "context_processors": [ + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + "django.template.context_processors.debug", + "django.template.context_processors.i18n", + "django.template.context_processors.media", + "django.template.context_processors.static", + "django.template.context_processors.csrf", + "django.template.context_processors.tz", + "django.template.context_processors.request", + ], + }, + } +] MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', @@ -111,13 +135,6 @@ # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'demoproject.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(APPLICATION_DIR, 'templates') -) - INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/test_requirements.txt b/test_requirements.txt index 94a0e83..5d9d601 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1 +1,2 @@ Django +Django-bower diff --git a/tests/test_template_tags.py b/tests/test_template_tags.py index 0d4b6bd..84ab9c9 100644 --- a/tests/test_template_tags.py +++ b/tests/test_template_tags.py @@ -6,8 +6,6 @@ Context, Template ) -from django.conf import settings -settings.configure() django.setup() from django.test.utils import override_settings try: