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

Django ImageField/FileField save uploaded file using model's pk

I'm converting a legacy site (originally written in rails) and by default the images were saved using the format {{pk}}.{{extension}} and that file was always overwritten if a new file is uploaded. I'd like to continue that format with this django…
oliverseal
  • 660
  • 8
  • 15
1
vote
1 answer

Django FileField - how to save files to different directories

I have two similar forms for upload files, but I want to save files in different directories depending on the form. Let me explain, for example: if User uploaded file from Form_1 -> file should be save in media/folder_file_1/file.csv if User…
1
vote
1 answer

Django model clean function validation error problem

I have a Django model with custom clean function as below: class License(models.Model): # fields of the model def clean(self): if condition1: raise ValidationError('Please correct the error!') The problem is that, my…
mohammad
  • 2,232
  • 1
  • 18
  • 38
1
vote
1 answer

MultiValueDictKeyError at /profiles/ uploading file

I am using the django framework. And I just want to upload an image. So I have this: views.py: # Create your views here. def store_file(file): with open("temp/mensschappy.png", "wb+") as dest: for chunk in file.chunks(): …
1
vote
1 answer

How to get the file object in `request.data` in Django?

Upload a tar file. How to get the file object in request.data? class AlbumViewSet(viewsets.ModelViewSet): @action(methods=['POST'], detail=False, url_path='upload-album') def upload_album(self, request): # Upload one tar file. …
1
vote
1 answer

How do i upload multiple image file into single models using Django rest framework?

I am stuck to upload a multiple image file at duration of creating doctor model .. I think to implement multiple upload, you need to set the additional field for uploading in the DoctorSerializer. I want to upload multiple images for each student…
1
vote
1 answer

how to get the last file uploaded to templates

i want to get the last file i was upload and it will be played in templates. but what i make it, every file i was upload, it can be played (so there’s so many audio player). what i want is just show 1 audio player with the last audio i was upload…
1
vote
2 answers

What's the difference between MEDIA_ROOT = BASE_DIR / 'media'` and MEDIA_ROOT= os.path.join(BASE_DIR, "media") in Django setting.py

I wanted to know the difference between using MEDIA_ROOT = BASE_DIR / 'media' and MEDIA_ROOT= os.path.join(BASE_DIR, "media") in settings.py.
nz_19
  • 61
  • 5
1
vote
0 answers

I'm trying to display pdf a file that i uploaded django FileField but it's not work

hello guys i try to display pdf file in my html page. i have this models: class HomeWork(models.Model): nameFile = models.CharField('Name File',max_length=30) file = models.FileField('File',upload_to="files",null=True) course =…
1
vote
0 answers

Can we upload multiple files at once in Django Admin site

I have a class named city. For this city, I have a filefield variable to upload the files. But I need to upload multiple files all at once in a single field in the Admin site (localhost:8000/admin). Could you please guide me with a sample code to…
1
vote
1 answer

which is the file word referring to here in this code

Here i have file in request.data['file'] and self.request.data.get('file') is this file referring to FileField in the model i need to upload file_2 as well how can i implement the code models.py: class FileUpload(models.Model): owner =…
1
vote
1 answer

Django automatic file-upload: [WinError 123] The filename, directory name, or volume label syntax is incorrect C:\\path\to\folder\C:

I'm pretty new to Django and I'm working on a project in which I have to automate PDF file uploads from a given folder to a model in Django and these files will undergo a text extraction process. I wrote a script to monitor the folder and upload new…
brdptr02
  • 31
  • 5
1
vote
3 answers

django file upload issue

I have tried to upload a picture using Django file field and in my models.py file class Students(models.Model): id = models.AutoField(primary_key=True) admin = models.OneToOneField(CustomUser, on_delete=models.CASCADE) gender =…
1
vote
0 answers

Getting a error "coInitialize has not been called" while converting a uploaded word file to pdf in django using docx2pdf

I am trying to convert an uploaded Docx file to pdf in Django using the docx2pdf module.But when I pass the file into the convert function I am getting the following error, pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.',…
1
vote
0 answers

Creating a multi-file uploader with Django Foreign Key

I am trying to create a JobRequestFile form where you can upload multiple files involving a foreign key to my JobRequest model. However, when trying to save, it takes me to my JobRequest form and says these fields are required. my form: class…