Skip to content
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ jobs:
strategy:
max-parallel: 4
matrix:
django-version: [2.2.27, 3.2.12, 4.0.2]
django-version: [4.2.20, 5.1.9, 5.2.1]

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -q Django==${{ matrix.django-version }} flake8 coverage djangorestframework
- name: Lint with flake8
run: |
flake8 --exclude vote/migrations/* vote
flake8 --exclude "vote/migrations/*" vote
- name: Test with coverage
run: |
coverage run runtests.py
Expand Down
1 change: 1 addition & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
],
DEFAULT_AUTO_FIELD='django.db.models.BigAutoField',
TEMPLATES=[
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
Expand Down
11 changes: 3 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@
"License :: OSI Approved :: Apache Software License",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 1.7",
"Framework :: Django :: 1.8",
"Framework :: Django :: 1.9",
"Framework :: Django :: 1.10",
"Framework :: Django :: 2.0",
"Framework :: Django :: 3.0",
"Framework :: Django :: 4.0",
"Programming Language :: Python :: 2.7",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.1",
"Framework :: Django :: 5.2",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
34 changes: 34 additions & 0 deletions vote/migrations/0001_squashed_0005_alter_vote_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.2.5 on 2025-12-01 14:57

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

replaces = [('vote', '0001_initial'), ('vote', '0002_auto_20161229_1022'), ('vote', '0003_vote_action'), ('vote', '0004_auto_20170110_1150'), ('vote', '0005_alter_vote_id')]

initial = True

dependencies = [
('auth', '__first__'),
('contenttypes', '__first__'),
]

operations = [
migrations.CreateModel(
name='Vote',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user_id', models.BigIntegerField()),
('object_id', models.PositiveIntegerField()),
('create_at', models.DateTimeField(auto_now_add=True)),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')),
('action', models.PositiveSmallIntegerField(default=0)),
],
options={
'unique_together': {('user_id', 'content_type', 'object_id', 'action')},
'index_together': {('content_type', 'object_id')},
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.5 on 2025-04-17 07:15

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('vote', '0004_auto_20170110_1150'),
]

operations = [
migrations.RenameIndex(
model_name='vote',
new_name='vote_vote_content_a520b4_idx',
old_fields=('content_type', 'object_id'),
),
]
2 changes: 1 addition & 1 deletion vote/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Vote(models.Model):

class Meta:
unique_together = ('user_id', 'content_type', 'object_id', 'action')
index_together = ('content_type', 'object_id')
indexes = [models.Index(fields=["content_type", "object_id"])]

@classmethod
def votes_for(cls, model, instance=None, action=UP):
Expand Down