Hi can anyone help me Im trying to do a filter on my form to filter an
email my code is a s follows any help on why this is not working will
be greatly appreciated
class Details(models.Model):
name = models.CharField(maxlength=80)
surname = models.CharField(maxlength=80)
number = models.CharField(maxlength=80)
email = models.EmailField()
def __str__(self):
return "%s %s" % (self.name, self.surname)
def competition(request):
EntryForm = forms.models.form_for_model(Details)
EntryForm.base_fields['country'].widget =
forms.Select(choices=COUNTRIES)
if request.method == 'POST':
object = None
form = EntryForm(request.POST)
if form.is_valid():
try:
object =
Details.objects.filter(email=form['email']) # THIS THE THE PROBLEM
LINE
except:
pass
if object is not None:
return HttpResponseRedirect('/refer/%s/' % object.id)
else:
entrant = form.save()
return HttpResponseRedirect('/refer/%s/' % entrant.id)
else:
form = EntryForm()
return render_to_response('competition/index.html', {'form':
form })
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---