Updated migrations to allow for a model with a non autofield as the primary key.
Updated tests.master
parent
d8df8bab55
commit
5d1529c161
Binary file not shown.
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Generated by Django 2.0 on 2018-03-20 01:17
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('samples', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TestNonAutoFieldModel',
|
||||||
|
fields=[
|
||||||
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||||
|
('order', models.PositiveIntegerField(db_index=True, editable=False)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ['order'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='category',
|
||||||
|
name='order',
|
||||||
|
field=models.PositiveIntegerField(default=0, editable=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import uuid
|
||||||
|
|
||||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
@ -249,3 +251,12 @@ class BackwardCompatibleWidget(Sortable, SimpleModel):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
|
class TestNonAutoFieldModel(SortableMixin):
|
||||||
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
|
order = models.PositiveIntegerField(editable=False, db_index=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ['order']
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ except ImportError:
|
||||||
import http.client as httplib # Python 3
|
import http.client as httplib # Python 3
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import uuid
|
|
||||||
|
|
||||||
import django
|
import django
|
||||||
|
|
||||||
|
|
@ -15,27 +14,7 @@ from django.test.client import Client
|
||||||
|
|
||||||
from adminsortable.models import SortableMixin
|
from adminsortable.models import SortableMixin
|
||||||
from adminsortable.utils import get_is_sortable
|
from adminsortable.utils import get_is_sortable
|
||||||
from .models import Category, Person, Project
|
from .models import Category, Person, Project, TestNonAutoFieldModel
|
||||||
|
|
||||||
|
|
||||||
class TestSortableModel(SortableMixin):
|
|
||||||
title = models.CharField(max_length=100)
|
|
||||||
|
|
||||||
order = models.PositiveIntegerField(default=0, editable=False)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
ordering = ['order']
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return self.title
|
|
||||||
|
|
||||||
|
|
||||||
class TestNonAutoFieldModel(SortableMixin):
|
|
||||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
||||||
order = models.PositiveIntegerField(editable=False, db_index=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
ordering = ['order']
|
|
||||||
|
|
||||||
|
|
||||||
class SortableTestCase(TestCase):
|
class SortableTestCase(TestCase):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue