diff --git a/sample_project/app/admin.py b/sample_project/app/admin.py index c79aaf4..3fca3f2 100644 --- a/sample_project/app/admin.py +++ b/sample_project/app/admin.py @@ -6,7 +6,7 @@ from adminsortable.admin import (SortableAdmin, SortableTabularInline, from adminsortable.utils import get_is_sortable from app.models import (Category, Widget, Project, Credit, Note, GenericNote, Component, Person, NonSortableCategory, SortableCategoryWidget, - SortableNonInlineCategory) + SortableNonInlineCategory, NonSortableCredit, NonSortableNote) admin.site.register(Category, SortableAdmin) @@ -56,8 +56,21 @@ class GenericNoteInline(SortableGenericStackedInline): extra = 0 +class NonSortableCreditInline(admin.TabularInline): + model = NonSortableCredit + extra = 1 + + +class NonSortableNoteInline(admin.StackedInline): + model = NonSortableNote + extra = 0 + + class ProjectAdmin(SortableAdmin): - inlines = [CreditInline, NoteInline, GenericNoteInline] + inlines = [ + CreditInline, NoteInline, GenericNoteInline, + NonSortableCreditInline, NonSortableNoteInline + ] list_display = ['__unicode__', 'category'] admin.site.register(Project, ProjectAdmin) diff --git a/sample_project/app/models.py b/sample_project/app/models.py index e90e85e..d882930 100644 --- a/sample_project/app/models.py +++ b/sample_project/app/models.py @@ -71,6 +71,25 @@ class Note(Sortable): return self.text +# Registered as a tabular inline on `Project` which can't be sorted +class NonSortableCredit(models.Model): + project = models.ForeignKey(Project) + first_name = models.CharField(max_length=30) + last_name = models.CharField(max_length=30) + + def __unicode__(self): + return '{0} {1}'.format(self.first_name, self.last_name) + + +# Registered as a stacked inline on `Project` which can't be sorted +class NonSortableNote(models.Model): + project = models.ForeignKey(Project) + text = models.CharField(max_length=100) + + def __unicode__(self): + return self.text + + # A generic bound model class GenericNote(SimpleModel, Sortable): content_type = models.ForeignKey(ContentType, @@ -97,6 +116,7 @@ class Component(SimpleModel, Sortable): return self.title + class Person(Sortable): class Meta(Sortable.Meta): verbose_name_plural = 'People' diff --git a/sample_project/database/test_project.sqlite b/sample_project/database/test_project.sqlite index 723eb74..6bbcbec 100644 Binary files a/sample_project/database/test_project.sqlite and b/sample_project/database/test_project.sqlite differ