Skip to content

Commit 6b44283

Browse files
committed
Define proper output_field on annotation
1 parent 455f469 commit 6b44283

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

readthedocs/redirects/querysets.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Queryset for the redirects app."""
22

33
from django.db import models
4-
from django.db.models import Value, CharField, Q, F, ExpressionWrapper
4+
from django.db.models import Value, CharField, IntegerField, Q, F, ExpressionWrapper
55
from django.db.models.functions import Substr, Length
66

77
from readthedocs.core.utils.extend import SettingsOverrideObject
@@ -41,21 +41,23 @@ def get_redirect_path_with_status(self, path, full_path=None, language=None, ver
4141

4242
from_length=ExpressionWrapper(
4343
Length('from_url'),
44-
output_field=CharField()
44+
output_field=IntegerField(),
4545
),
4646

4747
# 1-indexed
4848
from_url_without_rest=Substr(
4949
'from_url',
5050
1,
51-
F('from_length') - 5 # Strip "$rest"
51+
F('from_length') - 5, # Strip "$rest"
52+
output_field=CharField(),
5253
),
5354

5455
# 1-indexed
5556
full_path_without_rest=Substr(
5657
'full_path',
5758
1,
58-
F('from_length') - 5 # Strip "$rest"
59+
F('from_length') - 5, # Strip "$rest"
60+
output_field=CharField(),
5961
),
6062
)
6163
prefix = Q(

0 commit comments

Comments
 (0)