Questions tagged [django-file-upload]

Django-file-upload refers to how django handles file uploads

Django-file-upload refers to how django handles file uploads.

See documentation.

325 questions
1
vote
2 answers

Allow users to download files directly django

In the TrainerProfileModel I have file field called cv. I want to allow users to download the file directly when clicking on the link. Could you provide any ways to implement this? models.py: class TrainerProfile(models.Model): user =…
Mohit Harshan
  • 1,916
  • 1
  • 18
  • 41
1
vote
2 answers

Django-Upload file from HTML form to specific directory without using Django Forms

I can upload file and images from admin panel and it looks in the specified directory, but when I do so from the HTML form everything gets saved except the file. From Django admin panel, the file gets saved to media folder and I can access it from…
1
vote
1 answer

ImageField / FileField Django form Currently unable to trim the path to filename

I have a ImageField that stores in AWS S3 (similar to FileField). In the form, it has this "Currently" label that shows the image file path. I would like to trim and just show the filename. referring to the latest answer in Django : customizing…
Axil
  • 3,606
  • 10
  • 62
  • 136
1
vote
2 answers

django doesn't serve user-uploaded files in production

I deployed a website with django. it servs all static files but doesn't serve user-uploaded files. this is my settings.py and urls.py: import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = False STATIC_URL =…
msln
  • 1,318
  • 2
  • 19
  • 38
1
vote
1 answer

Django - FileField invalid literal for int() with base 10: 'media'

I'm making simple blog website in Django and I got this error: invalid literal for int() with base 10: 'media'. It's happnes when I added FileField to models.py in my blog application. Here is some code: models.py from django.db import models from…
xaos_xv
  • 759
  • 1
  • 10
  • 27
1
vote
2 answers

Django File Upload Not Saving To Filesystem

When I upload the file I get a "POST /submit/ HTTP/1.1" 200 604. When I check to see if the file uploaded I can't find it. Setting File includes: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) MEDIA_URL = '/media/' …
Jahmul14
  • 329
  • 4
  • 18
1
vote
1 answer

os.path.join() gives InMemoryUploadFile error

I have written a POST api which posts a file. I want to open the file and parse a JSON content in the file. But the line os.path.join() doesnt seem to work. I am getting "'InMemoryUploadedFile' object has no attribute 'startswith'" exception. Have…
1
vote
3 answers

Django FileSystemStorage.url is wrong

Code: company = Company.objects.get(pk=pk) if request.POST: company_name = request.POST['company_name'] company_logo = request.FILES['company_logo'] fs =…
dcolumbus
  • 9,596
  • 26
  • 100
  • 165
1
vote
1 answer

Uploading 2 single files on a form using separate inputs: Django

I'm trying to build an application that asks users to upload 2 different pdf files, each from a separate input button/area. I'm new to Django and through reading the documentation a bunch of times I've gotten a few things to work. Using
1
vote
0 answers

Saving file created inside the view to the backend (Django)

I have the following model : def upload_to(instance, filename): return os.path.join('/%s/' % instance.user.username, filename) class UserAudioAnswer(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL) question =…
1
vote
1 answer

Rotate image in template before upload in Django

May be somebody faced with such issue and found good solution. I need rotate image in template before upload and save the record. I can rotate image view in template using JavaScript but it doesn't give any results, because image saves in original…
Oleg
  • 777
  • 1
  • 6
  • 10
1
vote
1 answer

Handling uploaded files in Django

I am getting a file from user which is of xlsx or CSV format. I am saving the data of the files into my database using "django-excel". But after I perform request.FILES['file'].save_to_database() then if I try to access the uploaded file's contents…
1
vote
1 answer

Django: Got FieldDoesNotExist error when changing field type in models

I made a change in my models.py. I change the field from FileField() to ImageWithThumbsField() from mongoengine import * from gradfounder.settings import DBNAME from embed_video.fields import EmbedVideoField from thumbs import…
Aminah Nuraini
  • 18,120
  • 8
  • 90
  • 108
1
vote
1 answer

wrong file path when uploading a file in django

I have a following model for my files: class Import(models.Model): file = models.FileField(upload_to='%Y/%m/%d') And I save them like this: f = request.FILES['import'] if f.size < settings.MAX_UPLOAD_SIZE: x =…
nat
  • 1,511
  • 2
  • 11
  • 7
1
vote
1 answer

Upload new file to the model filefield

I have a model for Video: class Video(models.Model): title = models.CharField(max_length=75) pubdate = models.DateTimeField(default=timezone.now) original_video = models.FileField(upload_to=get_upload_file_name) mp4_720 =…
Robin
  • 5,366
  • 17
  • 57
  • 87