Last active
August 29, 2015 14:12
-
-
Save Hiieu/641532ecc2482fab61f2 to your computer and use it in GitHub Desktop.
Django email template problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Otrzymaliśmy od ciebie formularz: | |
Imię: {{ imie }} | |
Nick: {{ nick }} | |
Płeć: {{ plec }} | |
Wiek: {{ wiek }} | |
Miejscowość: {{ city }} | |
Email:{{ email }} | |
Telefon: {{ telefon }} | |
Wybrane spotkanie: {{ termin }} | |
Skąd się o nas dowiedzieliście: {{ feedback }} | |
<p><strong>HTML NIE DZIAŁA??!!</strong></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.contrib import messages | |
from django.core.mail import send_mail | |
from django.shortcuts import render | |
from django.http import HttpResponseRedirect, HttpResponse | |
from django.core.urlresolvers import reverse | |
from django.shortcuts import render_to_response | |
from .forms import Fields, SignUpJoin | |
from .models import SignUp | |
from django.core.mail import EmailMessage | |
from django.template.loader import get_template | |
from django.template import Context | |
from django.core.mail import EmailMultiAlternatives | |
from django.views.decorators.cache import cache_control, never_cache | |
# Create your views here. | |
@never_cache | |
@cache_control(no_cache=True, must_revalidate=True,no_store=True,max_age=0) | |
def zapisy(request): | |
form = SignUpJoin(request.POST or None) | |
if form.is_valid(): | |
save_it = form.save(commit=False) | |
save_it.save() | |
#send_mail(subject,message, from_email,fail_silently=True) | |
#POST datas | |
imie = request.POST.get('imie') | |
nick = request.POST.get('nick') | |
plec = request.POST.get('plec') | |
wiek = request.POST.get('wiek') | |
city = request.POST.get('city') | |
email = request.POST.get('email') | |
telefon = request.POST.get('telefon') | |
termin = request.POST.get('termin') | |
feedback = request.POST.get('feedback') | |
#end POST datas | |
ctx = { | |
'imie':imie, | |
'nick':nick, | |
'plec':plec, | |
'wiek':wiek, | |
'city':city, | |
'email':email, | |
'telefon':telefon, | |
'termin':termin, | |
'feedback':feedback, | |
} | |
subject = "Wawdating.pl" | |
message = get_template("email.html").render(Context(ctx)) | |
from_email = settings.EMAIL_HOST_USER | |
to_list =[save_it.email] | |
send_mail(subject,message, from_email, to_list,fail_silently=False) | |
return HttpResponseRedirect(reverse('zapisy-online/dziekujemy/')) | |
context = {'form':form} | |
template = "zapisy.html" | |
return render(request,template,context) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.contrib import messages | |
from django.core.mail import send_mail | |
from django.shortcuts import render | |
from django.http import HttpResponseRedirect, HttpResponse | |
from django.core.urlresolvers import reverse | |
from django.shortcuts import render_to_response | |
from .forms import Fields, SignUpJoin | |
from .models import SignUp | |
from django.core.mail import EmailMessage | |
from django.template.loader import get_template | |
from django.template import Context | |
from django.views.decorators.cache import cache_control, never_cache | |
# Create your views here. | |
@never_cache | |
@cache_control(no_cache=True, must_revalidate=True,no_store=True,max_age=0) | |
def zapisy(request): | |
form = SignUpJoin(request.POST or None) | |
if form.is_valid(): | |
save_it = form.save(commit=False) | |
save_it.save() | |
#send_mail(subject,message, from_email,fail_silently=True) | |
#POST datas | |
imie = request.POST.get('imie') | |
nick = request.POST.get('nick') | |
plec = request.POST.getlist('plec') | |
wiek = request.POST.get('wiek') | |
city = request.POST.get('city') | |
email = request.POST.get('email') | |
telefon = request.POST.get('telefon') | |
termin = request.POST.get('termin') | |
feedback = request.POST.get('feedback') | |
#end POST datas | |
ctx = { | |
'imie':imie, | |
'nick':nick, | |
'plec':plec, | |
'wiek':wiek, | |
'city':city, | |
'email':email, | |
'telefon':telefon, | |
'termin':termin, | |
'feedback':feedback, | |
} | |
subject = "Temat" | |
message = get_template("email.html").render(Context(ctx)) | |
from_email = settings.EMAIL_HOST_USER | |
to_list =[save_it.email] | |
send_mail(subject,message, from_email, to_list,fail_silently=False) | |
return HttpResponseRedirect(reverse('zapisy-online/dziekujemy/')) | |
context = {'form':form} | |
template = "zapisy.html" | |
return render(request,template,context) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Otrzymaliśmy od ciebie formularz: | |
Imię: Leszek | |
Nick: Śmieszek | |
Płeć: [u'2,'] <-----------Przy request.POST.getlist ciąg znaków zamiast "Mężczyzna"-----------> | |
Wiek: 71 | |
Miejscowość: Gdańsk | |
Email: [email protected] | |
Telefon: 070000222 | |
Wybrane spotkanie: 1 <-----------Przy request.POST.get value=1 zamiast "Warszawa 26.12.2014"-----------> | |
Skąd się o nas dowiedzieliście: Z internetu | |
<p><strong>HTML NIE DZIAŁA??!!</strong></p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment