So, I woke up this morning and went to go get the trace for you. Turned off my DEBUG setting in the settings.py and ran into some internal server errors. Fixed those, and then the messages error I was getting fixed itself, I guess. It's working now, randomly. Don't know what was causing it, guess it could've been my debug.
On Wednesday, December 14, 2016 at 9:32:02 AM UTC-8, Antonis Christofides wrote: > > Hi, > > could you show the full stack trace? > > Antonis Christofideshttp://djangodeployment.com > > On 12/14/2016 07:34 AM, Zachary Sohovich wrote: > > I'm attempting to add a success or error message to a form. As far as I > can see, I've added everything correctly. But, when I try to submit the > form with success or with error I get a 'NameError at /contact/' -> 'name > message not defined'. Note that it says name message (not plural) not > defined. Even though I only call messages. Here is my code > > # views.py > from django.shortcuts import render, redirectfrom django.contrib import > messagesfrom .models import Employeefrom .forms import EmailFormfrom > django.core.mail import send_mailfrom django.template import Contextfrom > django.template.loader import get_template > # Create your views here. > def home(request): > return render(request, 'index.html') > def team(request): > members = Employee.objects.all() > return render(request, 'team.html', {'members':members}) > def contact(request): > form_class = EmailForm > # forgive the unused code, will clean up later > if request.method == 'POST': > form = EmailForm(data=request.POST) > if form.is_valid(): > contact_name = request.POST.get('contact_name', '') > contact_email = request.POST.get('contact_email', '') > form_content = request.POST.get('content', '') > template = get_template('contact_template.txt') > context = > Context({'contact_name':contact_name,'contact_email':contact_email,'form_content':form_content,}) > content = template.render(context) > send_mail('Website Email from ' + > contact_name,content,contact_email, ['crowdc...@sneakycr0w.com > <javascript:>'], fail_silently=False) > messages.success(request,'Email was successful!') > else: > messages.error = messages.error(request, 'Fix the error') > return render(request, 'contact.html', {'form': form_class, }) > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users...@googlegroups.com <javascript:>. > To post to this group, send email to django...@googlegroups.com > <javascript:>. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/5a2531f3-ff59-4061-9cf2-7645c678c8e1%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/5a2531f3-ff59-4061-9cf2-7645c678c8e1%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/960f5c59-95c0-43c4-97a0-0804612d0c32%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.