#35348: Inconsistent behaviour with annotate using concat and GenericIPAddressField
-------------------------------------+-------------------------------------
Reporter: Lorenzo | Owner: nobody
Morandini |
Type: Bug | Status: new
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Concat function behaviour changed from django 3 to django 4 together with
GenericIPAddressField. In django 3 it would output only the ip address,
now a /32 is included too by default
Example model
{{{
class Example(models.Model):
ip_address = models.GenericIPAddressField(
_('ip address'), db_index=True, protocol='IPv4'
)
mask = models.PositiveIntegerField(
_('mask'),
)
Example.objects.all()
.annotate(
main_ip=Concat(
'ip_address',
V('/')
'mask'
)
)
}}}
With an example item with ip 192.168.1.1 and mask 30 the output would be:
in django 3 main_ip:
192.168.1.1/30
in django 4 main_ip:
192.168.1.1/32/30
Is this an expected behaviour? Happens only with concat, an annotate of
the ip_address field only produces the output '192.168.1.1'.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35348>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.