Last active
April 23, 2016 10:40
-
-
Save sivabudh/97fcdf962e18700050d32febbafcd22a to your computer and use it in GitHub Desktop.
Uploading file example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upload_file(request): | |
if request.method == 'POST': | |
form = NetworkScriptForm(request.POST, request.FILES) | |
if form.is_valid(): | |
content = request.FILES['file'].read() | |
networkscript = NetworkScript.objects.create( | |
title=request.POST['title'], | |
script=content, | |
) | |
return render(request, 'bod_detail.html', {'networkscript': networkscript}) | |
else: | |
form = NetworkScriptForm() | |
return render(request, 'networkscripts_upload.html', {'form': form}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment