Fixed views.py to accommodate form validation.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Thu, 03 Sep 2009 00:16:13 +0530
changeset 15 2dbb5e797989
parent 14 420517bb1a06
child 16 a5bbfbe5feb1
Fixed views.py to accommodate form validation.
template/index.html
upload/views.py
--- a/template/index.html	Wed Sep 02 23:51:12 2009 +0530
+++ b/template/index.html	Thu Sep 03 00:16:13 2009 +0530
@@ -38,7 +38,8 @@
 				<input type="submit" value="Upload" id="submit"/>
 			</form>
 		{% else %}			
-			Your Upload was successful!<br/>
+			Your Upload was successful!
+			You will be automatically redirected to the home page in 5 seconds<br/>
 			<script type="text/javascript"><!--
                 setTimeout('Redirect()',4000);
                 function Redirect()
--- a/upload/views.py	Wed Sep 02 23:51:12 2009 +0530
+++ b/upload/views.py	Thu Sep 03 00:16:13 2009 +0530
@@ -20,7 +20,9 @@
         if form.is_valid():
             #handle_uploaded_file(request.FILES['file'])
             form.save()	   
-        return render_to_response(template_name, {'form': ParticipantForm(), 'value': False,})
+            return render_to_response(template_name, {'form': form, 'value': False,})
+        else:
+            return render_to_response(template_name, {'form': form, 'value': True,})
     c = Context()
     return render_to_response(template_name,
 			  {'form': ParticipantForm(), 'value': True,})