Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango send_mail application - hook it up with Yeoman frontend
    primarykey
    data
    text
    <p>I'm using Django as backend and Yeoman as frontend. I'm new to both. My frontend local server is running on <code>localhost:9000</code>, and my backend server is running on <code>localhost:8000</code>. </p> <p>I just built an email sender application following the Django tutorial. It is working perfectly and consists of:</p> <p>A form:</p> <pre><code>class ContactForm(forms.Form): name = forms.CharField() email = forms.EmailField() telephoneNr = forms.IntegerField() message = forms.CharField(widget=forms.Textarea) </code></pre> <p>A view:</p> <pre><code>from django.core.mail import send_mail from django.shortcuts import render, render_to_response from django.http import HttpResponseRedirect, HttpResponse from mailsender.forms import ContactForm def contact(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): success = True name = form.cleaned_data['name'] email = form.cleaned_data['email'] telephoneNr = form.cleaned_data['tlf'] message= form.cleaned_data['melding'] receiverEmail = ['somewhere@example.com'] text = message +'\n'+name +'\n'+str(telephoneNr) send_mail('Contact form', beskjed, email, receiverEmail) return render(request,"result.html") else: form = ContactForm( return render(request, 'contactform.html', {'form':form}) </code></pre> <p>And my HTML:</p> <pre><code>&lt;h1&gt;Contact us&lt;/h1&gt; {% if form.errors %} &lt;p style="color: red;"&gt; Please correct the error{{ form.errors|pluralize }} below. &lt;/p&gt; {% endif %} &lt;form action="" method="post"&gt; &lt;table&gt; {{ form.as_p }} &lt;/table&gt; {% csrf_token %} &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; </code></pre> <p>If I visit <code>localhost:8000/contactform</code>, the contact form is displayed just as I want, and it does send emails.</p> <p>I need help figuring out how to hook up this view to the Yeoman frontend - as searching the Internetz (and SO) leads me to the path of confusion. Should I use <em>Tastypie</em>? I really want to keep this logic in the backend. Any help pointing me in the right direction is greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload