0
私はDjangoの非常に新しいユーザーです。私は、ボタンをクリックすると電子メール(ファックス用)を送信したいと思います。そこで、CustomerRequestUpdateView
のビューsend_fax
を作成しました。私はここで少し混乱しています。このメソッドはPOST要求を使用する必要がありますか?テンプレートに 'send_fax'をどのようにレンダリングできますか?私は、そのメソッドをクラスで直接実装することができれば幸いです。POSTかどうかrender_to_response()またはrender()?
class CustomerRequestUpdateView(RequestUpdateView):
template_name = 'loanwolf/customers/request.html'
url_namespace = 'customers'
def send_fax(self):
subject = 'The contract of %s' % self.customer.email_user
contact_message = 'This is just a test for later on during this project'
from_email = settings.EMAIL_HOST_USER
to_email = [from_email, ]
send_mail(
subject,
contact_message,
from_email,
to_email,
fail_silently=False,
)
return #render(request, template_name, context) render_to_pdf()
私はrender_to_response()
またはちょうどrender()
を使用することができると思ったが、私の方法を使用self
、ないrequest
。誰でもここで私を助けることができるだろうか?
ありがとうございます!
それは全く、関数のみが実行されるHTTP要求の1という名前呼ば立つような方法は、何もしないことを – Sayse
関連:[派遣コード](https://github.com /django/django/blob/master/django/views/generic/base.py#L78) – Sayse