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
0
votes
0 answers

How to use user uploaded image in Django template?

My problem is I am unable to use images in templates that are uploaded by an admin with admin interface. I have configured my settings and URLs according to documentation. In browser inspect element it is showing Uploaded image…
user9730761
0
votes
1 answer

Incorrect path to save the file in Django

I am now getting the file from my front-end and I set my model like this. model.py class User(models.Model): name = models.CharField(max_length=50) image= models.FileField(upload_to='image/', default=None) intro=…
0
votes
1 answer

File Browser configuration error: name 'settings' is not defined

I try to activate django-filebrowser-no-grappelli and I've use this indications for its configuration. Then I've updated setting.py with this: # Application definition INSTALLED_APPS = [ 'grappelli', 'filebrowser', 'tinymce', …
0
votes
1 answer

How do I convert a file to mp3 before saving django?

I found some information on extending and changing the save() method on my model, but a few other people mentioned that it was bad practice to do that, and one should instead modify the admin form. Extracting the audio from a mp4 is easy using…
0
votes
1 answer

Django: inlineformset 'attribute has no file associated with it' error

I have a inline formset set I can upload multiple instances of a model at once. How do you add a file? I keep getting that this error message 'The 'document' attribute has no file associated with it.' Error happens here: if…
Micah Pearce
  • 1,805
  • 3
  • 28
  • 61
0
votes
1 answer

Dynamic upload_to not working properly

I am trying to loop through my hard drive using python and storing the files in the database respectfully. My dynamic upload_to is working when uploading a file but when I try to save the file from the algorithm I wrote to loop through the hard…
0
votes
1 answer

Django FileUploadField Always Flunks Validation with "No File Uploaded" Error

I am using a django ModelForm and CreateView with AJAX form submission to allow a user to upload a file. Even after selecting a file, upon clicking submit, the field is set to blank and form fails validation claiming that no file has been…
cmanbst
  • 179
  • 3
  • 13
0
votes
0 answers

Why do I get different results?

I use Django 2.x. I try to upload the file "image.png". models.py: def file_name(instance, filename): return os.path.join('uploads', 'my_name.png') class FileForm(models.Model): file = models.FileField(upload_to=file_name, null=True) As a…
Valery
  • 321
  • 1
  • 13
0
votes
1 answer

django filefield renaming issue

I am using the following code to rename the filename path for a FileField in my model uploaded via a form: class Document(models.Model): document_date = models.DateField(null=True) document_category = models.CharField(null=False,…
cr1
  • 199
  • 2
  • 16
0
votes
1 answer

Django file saving to sqlite3 db and retrieval

The following is my device model: class Device(models.Model): device_type = models.ForeignKey(DeviceType,to_field='device_type') serial_number = models.CharField(max_length=200,unique=True) in_use_by =…
Aishwary Shukla
  • 450
  • 1
  • 7
  • 21
0
votes
1 answer

How can I upload files into django database

I want to upload files to the database that Django use, I know that I can do it through forms, but I want to read the files in my files system get the path of the docx or pdf and uploaded it into the database, how can I do that Here is the code…
AshMGM
  • 53
  • 8
0
votes
1 answer

Django clean: Determine the new line character in TemporaryFileUploadHandler chunk

During the upload of a file I need to split its contents in lines, count the characters of each line and raise and error if they exceed a certain length. class TheModel(models.Model): upload_file = models.FileField( upload_to='the/path' …
raratiru
  • 8,748
  • 4
  • 73
  • 113
0
votes
1 answer

Get header of CSV file in Django ModelForm

I'm building a django app that will let people upload CSVs that will be stored in S3 (based on django-storages) then processed by celery tasks which will then ingest them into the database. These CSVs can be any size, from a few rows (where Django…
NickCatal
  • 718
  • 7
  • 16
0
votes
1 answer

How do I read a zip(which in fact is in bytes form) without creating a temporary copy?

I am uploading a zip(which further contains pdf files to be read) as multipart/form-data . I am handling the upload as below: file = request.FILES["zipfile"].read() #gives a byte object bytes_io = io.BytesIO(file) # gives a IO stream object What I…
0
votes
1 answer

Django: Accept zip file having multiple image files in it through a Django form as FileField and operate on it

Class X(models.Model): zip_file = models.FileField() Now, this zip_file is a zip having any number of images. I want to be able to extract all the images and save (to DB) them under the same X object i.e. the "primary key" is the same. I…