Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
django-version: ['3.2', '4.0', '4.1']
experimental: [false]
include:
- python-version: pypy3
django-version: '3.2'
experimental: true
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
django-version: ['4.2', '5.2', '6.0']
exclude:
- python-version: "3.7"
django-version: "4.0"
- python-version: "3.7"
django-version: "4.1"
- python-version: '3.10'
django-version: '6.0'
- python-version: '3.11'
django-version: '6.0'
- python-version: '3.13'
django-version: '4.2'
- python-version: '3.14'
django-version: '4.2'

steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -43,13 +42,12 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Install Django ${{ matrix.django-version }}
run: pip install 'Django==${{ matrix.django-version }}'
run: pip install 'Django~=${{ matrix.django-version }}.0'

- name: Install django_userforeignkey
run: pip install .

- name: Run tests
continue-on-error: ${{ matrix.experimental }}
run: |
cd tests

Expand All @@ -61,4 +59,4 @@ jobs:
coverage xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]

### Added
- Added support for Django 4.2, 5.2 and 6.0
- Added support for Python 3.11, 3.12, 3.13 and 3.14

### Removed
- Dropped support for Django 3.2, 4.0 and 4.1
- Dropped support for Python 3.7, 3.8 and 3.9


## [0.5.0]

### Added
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ Django UserForeignKey is a simple Django app that will give you a `UserForeignKe
This field extends a regular ForeignKey model field, and has the option to automatically set the currently logged in
user on insert and/or update.

Currently, Django 3.2 (Python 3.7+) and Django 4.0 & 4.1 (Python 3.8+) are supported.
Currently, Django 4.2, 5.2 and 6.0 are supported (Python 3.10+).

If you need support for the insecure and deprecated Python 3.6, please fall back to version 0.4.0.
If you need support for Django 3.2 or 4.0/4.1, please fall back to version 0.5.0.

If you need support for the insecure and deprecated Django 1.11 and/or Python2, please fall back to version 0.3.0.

If you need support for the insecure and deprecated Django 1.8 (and possibly 1.9 and 1.10), please fall back to
version 0.2.1.
If you need support for the insecure and deprecated Django 1.11 and/or Python 2, please fall back to version 0.3.0.

There also is a [video tutorial on YouTube](https://www.youtube.com/watch?v=iJCbYMgUDW8>) that shows you basic
functionality of this package.
Expand Down Expand Up @@ -71,7 +68,7 @@ associated.

## Configuration options

The configuration options are similar to Django's [DateField](https://docs.djangoproject.com/en/4.1/ref/models/fields/#datefield).
The configuration options are similar to Django's [DateField](https://docs.djangoproject.com/en/6.0/ref/models/fields/#datefield).

* `auto_user`: Automatically sets the current user everytime the object is saved (e.g., created or updated). This is
useful for **last modified by** information.
Expand Down
11 changes: 3 additions & 8 deletions django_userforeignkey/middleware.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# -*- coding: utf-8 -*-
import logging
from django_userforeignkey.request import set_current_request

# import Django 1.10 middleware
try:
from django.utils.deprecation import MiddlewareMixin
except:
# Django 1.8 and 1.9 compatibility
class MiddlewareMixin(object):
pass
from django.utils.deprecation import MiddlewareMixin

from django_userforeignkey.request import set_current_request


logger = logging.getLogger(__name__)
Expand Down
16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,26 @@
url='https://github.com/beachmachine/django-userforeignkey/',
author='Andreas Stocker',
author_email='andreas@stocker.co.it',
python_requires='>=3.10',
install_requires=[
'Django>=4.2',
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.2',
'Framework :: Django :: 5.2',
'Framework :: Django :: 6.0',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
from django.utils.timezone import utc
from datetime import timezone as tz
import django_userforeignkey.models.fields


Expand Down Expand Up @@ -34,7 +34,7 @@ class Migration(migrations.Migration):
('question', models.CharField(max_length=200)),
('pub_date', models.DateTimeField(verbose_name=b'Publication date of poll')),
('created_by', django_userforeignkey.models.fields.UserForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='polls', to=settings.AUTH_USER_MODEL, verbose_name=b'The user that created the poll')),
('created_at', models.DateTimeField(auto_now_add=True, default=datetime.datetime(2016, 4, 14, 13, 32, 11, 409531, tzinfo=utc), verbose_name=b'Publication date of poll')),
('created_at', models.DateTimeField(auto_now_add=True, default=datetime.datetime(2016, 4, 14, 13, 32, 11, 409531, tzinfo=tz.utc), verbose_name=b'Publication date of poll')),
],
),
migrations.AddField(
Expand Down
17 changes: 6 additions & 11 deletions tests/test_project/polls/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import datetime
from django.contrib.auth.models import AnonymousUser, User

try:
# Django 1.10 and above
from django.urls import reverse
except:
# Django 1.8 and 1.9
from django.core.urlresolvers import reverse
from django.urls import reverse

from django.utils import timezone
from django.test import TestCase
Expand Down Expand Up @@ -79,15 +74,15 @@ def test_index_view_with_no_polls(self):
response = self.client.get(reverse('polls:index'))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "No polls are available.")
self.assertQuerysetEqual(response.context['latest_poll_list'], [])
self.assertQuerySetEqual(response.context['latest_poll_list'], [])

def test_index_view_with_a_past_poll(self):
"""
Polls with a pub_date in the past should be displayed on the index page.
"""
poll = create_poll(question="Past poll.", days=-30)
response = self.client.get(reverse('polls:index'))
self.assertQuerysetEqual(
self.assertQuerySetEqual(
response.context['latest_poll_list'],
[poll]
)
Expand All @@ -100,7 +95,7 @@ def test_index_view_with_a_future_poll(self):
create_poll(question="Future poll.", days=30)
response = self.client.get(reverse('polls:index'))
self.assertContains(response, "No polls are available.", status_code=200)
self.assertQuerysetEqual(response.context['latest_poll_list'], [])
self.assertQuerySetEqual(response.context['latest_poll_list'], [])

def test_index_view_with_future_poll_and_past_poll(self):
"""
Expand All @@ -110,7 +105,7 @@ def test_index_view_with_future_poll_and_past_poll(self):
past_poll = create_poll(question="Past poll.", days=-30)
create_poll(question="Future poll.", days=30)
response = self.client.get(reverse('polls:index'))
self.assertQuerysetEqual(
self.assertQuerySetEqual(
response.context['latest_poll_list'],
[past_poll]
)
Expand All @@ -122,7 +117,7 @@ def test_index_view_with_two_past_polls(self):
past_poll_1 = create_poll(question="Past poll 1.", days=-30)
past_poll_2 = create_poll(question="Past poll 2.", days=-5)
response = self.client.get(reverse('polls:index'))
self.assertQuerysetEqual(
self.assertQuerySetEqual(
response.context['latest_poll_list'],
[past_poll_2, past_poll_1]
)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True


Expand Down