Skip to content

Nested inlines FileField upload broken – field omitted on save #1960

Description

@SpirikStar
Image

What version of Unfold are you using?

0.87.0

What version of Django are you using?

6.0.3

What browser are you using?

For example: Firefox 148.0

Did you checked changelog/commit history, if the bug is not already fixed?

For example: Yes

Did you searched other issues, if the bug is not already fixed?

For example: No

Did you checked documentation?

Yes.

Are you able to replicate the bug in the demo site?

No.

Repository with reproduced bug

Create minimal repository where it is possible to reproduce an error.

Describe your issue
I use nested inlines. The problem arises because when I try to upload a file, the file name itself appears in the display name, but when saving, it writes an error (the field is omitted). I've redefined the problem in a new project, but it hasn't been resolved.

#admin.py
from django.contrib import admin
from unfold.admin import ModelAdmin, StackedInline, TabularInline
from appUpload import models as models_upload


class FileInline(TabularInline):
    model = models_upload.File
    extra = 0

class ItemInline(StackedInline):
    model = models_upload.Item
    inlines = [FileInline]

    tab = True
    extra = 0

@admin.register(models_upload.Root)
class Root(ModelAdmin):
    inlines = [ItemInline]
#models.py
from django.db import models

class Root(models.Model):
    name = models.CharField()
    created_at = models.DateTimeField(auto_now_add=True)

class Item(models.Model):
    name = models.CharField()
    status = models.BooleanField()
    root = models.ForeignKey(Root, on_delete=models.CASCADE)

class File(models.Model):
    name = models.CharField()
    file = models.FileField()
    item = models.ForeignKey(Item, on_delete=models.CASCADE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions