我如何使用django的runscript?

时间:2019-04-30 01:39:20

标签: django

我正在尝试使用Django的runscript运行脚本。我遵循了文档中的所有内容。我错过了什么吗?

Here is the files that i created

但是当我尝试从命令行运行它时。它说未知命令“ runscript”

(env)C:\ Users \ MIS \ hr system \ hr_project> python manage.py runscript automail.py 未知命令:“ runscript”

1 个答案:

答案 0 :(得分:1)

如果要使用add_action('wpcf7_before_send_mail', 'wpcf7_update_email_body'); function wpcf7_update_email_body($contact_form) { $submission = WPCF7_Submission::get_instance(); if ( $submission ) { /* DEFINE CONSTANT AND GET FPDF CLASSES */ define ('FPDF_PATH',get_template_directory().'/wp-content/themes/escapade/fpdf/'); // MAKE SURE THIS POINTS TO THE DIRECTORY IN YOUR THEME FOLDER THAT HAS FPDF.PHP require(FPDF_PATH.'fpdf.php'); $posted_data = $submission->get_posted_data(); // SAVE FORM FIELD DATA AS VARIABLES $name = $posted_data["your-name"]; $email = $posted_data["your-email"]; $message = $posted_data["your-message"]; $verifyeft = $posted_data["verifyeft"]; $expensecategory = $posted_data["expensecategory-892"]; $purpose = $posted_data["your-purpose"]; $pretax = $posted_data["pretax-837"]; $tax = $posted_data["tax-424"]; $totalamount = $posted_data["totalamount-101"]; $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Write(5,$name . "\n\n" . $email . "\n\n" . $message . "\n\n" . $verifyeft . "\n\n" . $expensecategory . "\n\n" . $purpose . "\n\n" . $pretax . "\n\n" . $tax . "\n\n" . $totalamount); $pdf->Output(FPDF_PATH.'test.pdf', 'F'); // OUTPUT THE NEW PDF INTO THE SAME DIRECTORY DEFINED ABOVE } } add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' ); function mycustom_wpcf7_mail_components($components){ if (empty($components['attachments'])) { $components['attachments'] = array(FPDF_PATH .'expenseform.pdf'); // ATTACH THE NEW PDF THAT WAS SAVED ABOVE } return $components; } 命令,则需要安装django-extensions。如果您不想这样做,可以:

  • 直接运行脚本。请记住,您需要这样指定Django设置模块:
runscript