Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is SortableStackedInline compatible with django-polymorphic? #386

Open
deanknudsondowner opened this issue Mar 1, 2024 · 0 comments
Open

Comments

@deanknudsondowner
Copy link

deanknudsondowner commented Mar 1, 2024

Hi ive been trying to get SortableStackedInline working with django-polymorphic and I cant seem to get the moveable boxes working on the inlines. Is this actually possible with this module? I took a look at this closed issue but it didn't end up helping.

models:

class PageObject(PolymorphicModel):
    uuid = models.UUIDField(default=uuid.uuid4, editable=False)
    page = models.ForeignKey(AggregatePage, on_delete=models.CASCADE)
    position = models.PositiveIntegerField(default=0, blank=False, null=False)

    class Meta:
        ordering = ['position']


class CameraPageObject(PageObject):
    camera = models.ForeignKey(Camera, on_delete=models.CASCADE)


class EmbedPageObject(PageObject):
    name = models.CharField(max_length=150, blank=False, null=False)
    url = models.URLField(blank=False, null=False)

admin:

class PageObjectInline(StackedPolymorphicInline):
    class CameraPageObjectInline(StackedPolymorphicInline.Child, SortableStackedInline):
        model = CameraPageObject

    class EmbedPageObjectInline(StackedPolymorphicInline.Child, SortableStackedInline):
        model = EmbedPageObject

    model = PageObject
    child_inlines = [CameraPageObjectInline, EmbedPageObjectInline]


@admin.register(AggregatePage)
class AggregatePageAdmin(SortableAdminBase, PolymorphicInlineSupportMixin, admin.ModelAdmin):
    formfield_overrides = {models.ManyToManyField: {'widget': CheckboxSelectMultiple}}
    inlines = [PageObjectInline]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant