Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute python command in django admin panel

Tags:

python

django

Is it possible to execute python command in admin panel or in django view?I. e. if I would like to sync database in my app using a button.

like image 491
szaman Avatar asked Feb 13 '26 05:02

szaman


1 Answers

Write a custom admin view featuring a form, and when the form is submitted in the view call django.core.management.call_command

Remark regarding using a form: As your request will change things at the server-side, a post must be preferred over a get.

like image 132
shanyu Avatar answered Feb 14 '26 17:02

shanyu