KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Ok more on forms. I have finally got my form to validate, post and redirect to page it needs to. Now my issue is when I return to the page with the form I get this error: Caught AttributeError while rendering: 'WSGIRequest' object has no attribute 'get' Seems the only way to restore it to work is to delete the forms.py replacing what was not working before. Add what is working and I can get it to work ONCE. Any ideas what can cause this issue? FORMS: class LeadSubmissionForm(forms.ModelForm): """ A simple default form for messaging. """ class Meta: model = Lead fields = ( 'parent_or_student', 'attending_school', 'how_much', 'year_of_study', 'zip_code', 'email_address', 'graduate_year', 'graduate_month', 'email_loan_results' ) VIEWS: @render_to("lender/main_views/home.html") def home(request): if request.method == 'POST': form = LeadSubmissionForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("search_results")) else: form = LeadSubmissionForm(request) testimonials = Testimonial.objects.filter(published=True)[:3] return {'lead_submission_form':form, 'testimonials': testimonials,} MODELS: class Lead(TitleAndSlugModel): """ A lead submitted through the site (i.e. someone that has at-least submitted the search form """ PARENT_OR_STUDENT = get_namedtuple_choices('PARENT_OR_STUDENT', ( (0, 'PARENT', 'Parent'), (1, 'STUDENT', 'Student'), )) YEARS_OF_STUDY = get_namedtuple_choices('YEARS_OF_STUDY', ( (0, 'ONE', '1'), (1, 'TWO', '2'), (2, 'THREE', '3'), (3, 'FOUR', '4'), )) parent_or_student = models.PositiveIntegerField(choices=PARENT_OR_STUDENT.get_choices(), default=0)
Tags (comma-separated)
Save Edits
Cancel