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

can't "publish" a draft in a snippet with InlinePanel with files #11882

Open
cesarbenjamindotnet opened this issue Apr 22, 2024 · 4 comments
Open
Labels
status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. type:Bug

Comments

@cesarbenjamindotnet
Copy link

cesarbenjamindotnet commented Apr 22, 2024

Issue Summary

I have problem saving files on ParentalKey field when using it with InlinePanel and DraftStateMixin, RevisionMixin togheter

Steps to Reproduce

I have a Snippet Model who extends ClusterableModel, this because i have the need to have a related model to add many Orderable Objects with a File Field:


class MainModel(ClusterableModel, LockableMixin, WorkflowMixin, DraftStateMixin, RevisionMixin):
    name = models.CharField(max_length=255)
    # ... and other fields which don't matter, there is no issues with other things

and then:

class ResourceFile(Orderable):
    uuid = models.UUIDField(default=uuid.uuid4, editable=False)
    file = models.FileField(upload_to='resources/files/')
    resource = ParentalKey(MainModel, on_delete=models.CASCADE, related_name="resource_files") 

then, i register a snippet with:

@register_snippet
class MainModelSnippetViewSet(SnippetViewSet):
    model = MainModel
    menu_label = "Main Model"

    add_to_admin_menu = False
    search_fields = ("name",)

    main_panels = [
        FieldPanel('name'),
        # ...
    ]

    files_panels = [
        InlinePanel('resource_files', panels=[
            FieldPanel('uuid', read_only=True),
            FieldPanel('file'),
        ], min_num=1),
    ]

    edit_handler = TabbedInterface([
        ObjectList(main_panels, heading='Main'),
        ObjectList(files_panels, heading='Files'),
    ])

The thing works fine if i save with publish button, but if i save as draft, it saves, but when i try to publish, it throws and error showing "This field is required." error in file field in all entries added on draft

imagen

imagen

imagen

Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?

  • I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes

Technical details

  • Python version: 3.11
  • Django version: 5.04
  • Wagtail version: 5.2.4
  • Browser version: Firefox 124
@cesarbenjamindotnet cesarbenjamindotnet added status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. type:Bug labels Apr 22, 2024
@cesarbenjamindotnet
Copy link
Author

not sure if i was clear enough: i can save well all the time if i only use publish, i can add a few files first time and save with publish, and i can add more files and saving with publish goes well all times. But if i use save draft then i can't save anymore until i remove the entires and upload again and save with publish, but i want to can save drafts or workflows.

thanks

@laymonage
Copy link
Member

Might be related to a similar issue for pages: #10814

We generally recommend using Documents to upload files to the CMS. I'm not sure to what extent we support FileFields, but I don't think we have a test case for this. We only have very simple test models that use FileField, and I'm sure there are other places where we haven't fully supported FileFields (the preview mechanism comes to mind).

@cesarbenjamindotnet
Copy link
Author

i know the common way to handle files is using Documents but my use case have certain constraints about the "meaning" of files in this particular Model. I know that Wagtail focuses on Content and there is natural mind on choosing reosurces as files and images from collections maybe many times. But in my case i have to upload a File once per model to read contents and populate ceraint other models. So, is not useful to endusers handle apart the files in a common place of files, i know that can be used roles to jail access per folder but is not either useful; my use case minds "a file" like any other input for unique usage at a time and not be able to see it across the admin ui outer of the specific object instance only.

Please see this video ( https://www.youtube.com/watch?v=8F_V2YSsThI ), is on django admin, not wagtail admin, was a sketchy try but more or less is the thing i'm trying to do: i have to upload one (or many) files, process it using spatial analytics and remote sense things, and then i got a lot of data that i have to save again, once uploaded and saved there is no need to access again to the file so i don't need Documents API, but i will like to have wagtail Revisions and DraftState features to be able to handle data again if a new revisión is made; so, i have to handle files in "direct" way

@cesarbenjamindotnet
Copy link
Author

then, is there intentions to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. type:Bug
Projects
None yet
Development

No branches or pull requests

2 participants