Changes between Version 1 and Version 2 of Ticket #23121, comment 5


Ignore:
Timestamp:
Sep 7, 2018, 1:03:07 PM (6 years ago)
Author:
bacilla

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #23121, comment 5

    v1 v2  
    11The same bug in version 2.1. Test project in attachment.
    22
     3Test model:
     4{{{#!python
     5from django.db import models
     6from django.db.models.functions import Cast, Concat, Right
     7
     8
     9class TestEntity(models.Model):
     10    some_property = models.TextField()
     11
     12    class Meta:
     13        ordering = ('some_property',)
     14}}}
     15
    316Migrations log:
    4 {{{
     17{{{#!bash
    518$ python manage.py makemigrations app
    619Migrations for 'app':
     
    1023
    1124Then ordering have been changed.
    12 {{{
     25
     26{{{#!python
     27class TestEntity(models.Model):
     28    some_property = models.TextField()
     29
     30    class Meta:
     31        ordering = (
     32            Cast(models.Func(models.F('some_property'), models.Value('^\d+'), function='SUBSTRING'), models.IntegerField()),
     33            Right(Concat(models.Value('00000'), models.F('some_property')), models.Value(5))
     34        )
     35}}}
     36
     37Migrations log:
     38{{{#!bash
    1339$ python manage.py makemigrations app
    1440Migrations for 'app':
Back to Top