8000 upgrade django to 4.2 by chriswedgwood · Pull Request #557 · django/djangosnippets.org · GitHub
[go: up one dir, main page]

Skip to content

upgrade django to 4.2 #557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2025
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
50 changes: 50 additions & 0 deletions cab/migrations/0006_alter_snippet_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Generated by Django 4.2.23 on 2025-06-22 09:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("cab", "0005_alter_snippet_tags"),
]

operations = [
migrations.AlterField(
model_name="snippet",
name="version",
field=models.CharField(
choices=[
("5.2", "5.2"),
("5.1", "5.1"),
("5.0", "5.0"),
("4.2", "4.2"),
("4.1", "4.1"),
("4.0", "4.0"),
("3.2", "3.2"),
("3.1", "3.1"),
("3.0", "3.0"),
("2.2", "2.2"),
("2.1", "2.1"),
("2.0", "2.0"),
("1.11", "1.11"),
("1.10", "1.10"),
("1.9", "1.9"),
("1.8", "1.8"),
("1.7", "1.7"),
("1.6", "1.6"),
("1.5", "1.5"),
("1.4", "1.4"),
("1.3", "1.3"),
("1.2", "1.2"),
("1.1", "1.1"),
("1.0", "1.0"),
("0.96", ".96"),
("0.95", "Pre .96"),
("0", "Not specified"),
],
default="0.0",
max_length=5,
),
),
]
23 changes: 23 additions & 0 deletions ratings/migrations/0002_alter_rateditem_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.23 on 2025-06-22 09:58

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


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("ratings", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="rateditem",
name="user",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, related_name="%(class)ss", to=settings.AUTH_USER_MODEL
),
),
]
4 changes: 2 additions & 2 deletions ratings/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,8 @@ class QueryHasWhereTestCase(TestCase):

def test_without_where_clause(self):
result = ratings_utils.query_has_where(Food.objects.all().query)
self.assertTrue(result)
self.assertFalse(result)

def test_with_where_clause(self):
result = ratings_utils.query_has_where(Food.objects.filter(name="test").query)
self.assertFalse(result)
self.assertTrue(result)
10 changes: 7 additions & 3 deletions ratings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import FullResultSet
from django.db import connection


Expand All @@ -11,8 +12,11 @@ def is_gfk(content_field):


def query_has_where(query):
where, params = query.get_compiler(using="default").compile(query.where)
return where == ""
try:
where, params = query.get_compiler(using="default").compile(query.where)
return bool(where)
except FullResultSet:
return False


def query_as_sql(query):
Expand Down Expand Up @@ -216,7 +220,7 @@ def _store_top_matches(ratings_queryset, rated_queryset, num, is_gfk):

for item in rated_queryset.iterator():
matches = top_matches(ratings_queryset, rated_queryset, item, num)
for (score, match) in matches:
for score, match in matches:
si, created = SimilarItem.objects.get_or_create(
content_type=ctype,
object_id=item.pk,
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bleach==6.2.0
Django==4.1.13
Django==4.2.23
dj-database-url==0.5.0
django-allauth==0.63.6
django-contrib-comments==2.2.0
Expand Down
0