Ok más en formularios. Finalmente obtuve mi formulario para validar, publicar y redirigir a la página que necesita. Ahora mi problema es cuando regrese a la página con el formulario consigo este error:Capturado AttributeError durante la representación: el objeto 'WSGIRequest' no tiene ningún atributo 'get'
Atrapados AttributeError mientras que la prestación: objeto 'WSGIRequest' no tiene atributo 'conseguir'
Parece que la única manera de restaurarlo a trabajar es eliminar el forms.py reemplazando lo que no funcionaba antes. Agregue lo que está funcionando y puedo hacer que funcione UNA VEZ. ¿Alguna idea de lo que puede causar este problema?
FORMAS:
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'
)
Vistas:
@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,}
MODELOS:
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)
attending_school = models.ForeignKey(School)
how_much = models.DecimalField(max_digits=10, decimal_places=2)
year_of_study = models.PositiveIntegerField(choices=YEARS_OF_STUDY.get_choices(), default=0)
zip_code = models.CharField(max_length=8)
email_address = models.EmailField(max_length=255)
graduate_year = models.IntegerField()
graduate_month = models.IntegerField()
email_loan_results = models.BooleanField(default=False)
def __unicode__(self):
return "%s - %s" % (self.email_address, self.attending_school)
Una vez más cualquier ayuda es de gran ayuda. ¡¡Gracias!!
¡Eso fue todo! ¡Muchas gracias, Brandon! – tjoenz