Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Gerald Wells
12,763 Pointsinvalid syntax Django
when I saved my view.py it threw an error of "invalid syntax" I'm not seeing an issue.
messages.add_message(request, message.SUCCESS, "Message sent!")

Gavin Ralston
28,770 PointsWhen you say "it threw an error" was there a more specific message? Or did python simply say "invalid syntax" and crash?
The stack trace would come in handy here, if you could post it.
3 Answers

Gavin Ralston
28,770 Pointsdef contact_form(request):
form = forms.ContactForm()
if request.method == 'POST':
form = form.ContactForm(request.POST)
The second asignment is assigning form.ContactForm() instead of forms.ContactForm()
So I'm guessing the syntax error is there because there is no new_message method on that item.

Gerald Wells
12,763 PointsIt simply said "invalid syntax" crashed it said the invalid syntax can from line 30 the '^' was at the 'e' of messages.

Gerald Wells
12,763 Pointsmessages.add_message(request, messages.SUCCESS, "Message sent!")
^
SyntaxError: invalid syntax

Gerald Wells
12,763 PointsIt was there and a closing ) after ['name']
Gerald Wells
12,763 PointsGerald Wells
12,763 Pointswhole view: