M
M
mcrack2021-09-04 16:08:23
Django
mcrack, 2021-09-04 16:08:23

How to pass filename to Django widget?

Hello, I found such a plugin for Django that crops the image before uploading, it has a file_name parameter, but I don’t want to manually write the file name, I need the title to be converted (for example, to transliteration) and this name is already assigned to the file_name parameter.

In general, please tell me how and in what place to write a function that would have access to the title parameter and which can be used in the widget as follows: file_name=funcName()

Link to the plugin github:
https://github.com/koendewit /django-client-side-im...

class EbookForm(forms.ModelForm):
    class Meta:
        model = Ebook
        fields = ['title', 'cover_photo']
        
        widgets = {
            'cover_photo': ClientsideCroppingWidget(
                width=400,
                height=600,
                preview_width=100,
                preview_height=150,
                clearable=True,
                quality=75,
                format='jpeg',
                file_name='тут должно быть название файла'
            )
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question