The use of manage.py Command in django

recently using django-ckeditor as a third-party package, one of the commands is that manage.py generateckeditorthunbnails can generate a thumbnail of the uploaded file under the project path, but do you have to execute this command on the command line every time you upload a picture? Or can you write a script to execute it?
my original intention is to get a thumbnail of the picture of the article as a summary of each blog post on the home page, but it"s stuck here, and I don"t know what idea is a little better than mine.

Feb.22,2022

it is recommended to execute a task call create_thumbnail to generate thumbnails after handling the operation of uploading pictures


Django custom management command is achieved by creating a py file with the same name as the command under the management/commands directory of app. For example, if you have a mycmd.py file in the app1/management/commands directory, you can execute the custom command python manage.py mycmd with app1 enabled. The same is true for third-party applications. I don't know why this package chose to generate thumbnails as a command rather than an API, but you can find the installation directory of this third-party package after pip install django-ckeditor, open the management/commands/generateckeditorthunbnails.py file, and see how the handle part of it is written, so that you can port this part of the code logic to your own program.

Menu