Created
October 1, 2014 00:58
-
-
Save anonymous/70d6740afcb678c7b0f8 to your computer and use it in GitHub Desktop.
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
# In the console, this is all that's printed: | |
# [01/Oct/2014 00:51:33] "POST /StubAcceptFile HTTP/1.1" 500 9935 | |
SETTINGS: | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.sqlite3', | |
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | |
} | |
} | |
MODEL: | |
class Uploaded_File(models.Model): | |
def file_destination(instance, filename): | |
return 'user_uploads/' + instance.generated_id | |
generated_id = models.CharField(max_length=25) | |
uploaded_file = models.FileField(upload_to=file_destination) | |
VIEW: | |
def StubAcceptFile(HttpRequest): | |
file_data = HttpRequest.FILES["uploaded_excel_file"] | |
file_id = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits*2) for x in range(25)) | |
new_uploaded_file = Uploaded_File(uploaded_file=file_data, generated_id=file_id) | |
new_uploaded_file.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment