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
8
votes
3 answers

Get the file size of the uploaded file in Django app

I would like show in the template the size of a file that the user have uploaded. I've see that the file object has the attribute size but, because I'm newbie with Python and the development field, I've been trouble to understand how I can use…
MaxDragonheart
  • 1,117
  • 13
  • 34
7
votes
1 answer

FileField: force using TemporaryUploadedFile

When uploading a file for a field such as this one: file = FileField(upload_to='/path/') Django uses either an InMemoryUploadedFile or a TemporaryUploadedFile. The latter is stored on the disk and its file name can be accessed with the…
mimo
  • 2,469
  • 2
  • 28
  • 49
7
votes
3 answers

AttributeError: 'file' object has no attribute '_committed'

I have a DjangoFileField in my model. I am trying to convert the type of the audio from that FielField to mp3 and then again trying to save it. But after converting the type and exporting it using pydub it is returning the following error …
Abdul Rauf
  • 117
  • 1
  • 2
  • 7
7
votes
1 answer

Displaying the contents (rather than saving) of an uploaded file with Django

How can I have a form with a FileField, where the uploaded file will not be saved but instead its text contents will be extracted and displayed?
Ron
  • 71
  • 1
  • 2
7
votes
1 answer

Django - uploading static image as default ImageField file

This is my models.py: def get_profileImage_file_path(instance, filename): return os.path.join('%s/uploadedPhotos/profileImages' % instance.user_id, filename) class UserExtended(models.Model): user = models.OneToOneField(User) …
SilentDev
  • 20,997
  • 28
  • 111
  • 214
6
votes
5 answers

How does one use magic to verify file type in a Django form clean method?

I have written an email form class in Django with a FileField. I want to check the uploaded file for its type via checking its mimetype. Subsequently, I want to limit file types to pdfs, word, and open office documents. To this end, I have installed…
dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206
6
votes
2 answers

django 'thumbnail' is not a valid tag library:

I have tried django-filer to select mulitple files in a single filefield just i tried for my simple model and i ma facing this template error. i have just used a simple model in django admin. could you please help me? class MyFile(models.Model): …
Nava
  • 6,276
  • 6
  • 44
  • 68
6
votes
1 answer

Django forms : Edit image field (delete and show existing)

I am trying to have a Django Model form with an image field but I have the two problems: I don't know how to show the current name of the image in the input I don't know how to provide a way to remove the image forms: class…
BleuBizarre
  • 368
  • 2
  • 15
6
votes
1 answer

django rest framework get request in serializer create method

I'm a student studying django rest framework I tried to upload multiple file with form-data when i send request like this in postman error occurs and this is error message images_data = self.context.get('request').request.FILES AttributeError:…
6
votes
2 answers

update forms.FileField on django forms

I have a model with a FileField in it: class DocumentUpload(models.Model): document_name = models.CharField(max_length=100, blank=True) document_path = models.FileField(upload_to='uploads') and a form which uses this model class…
John
  • 21,047
  • 43
  • 114
  • 155
6
votes
3 answers

Django CMS - not able to upload images through cmsplugin_filer_image

i have a problem with a local installation on django cms 2.3.3: i've installed it trough pip, in a separated virtualenv. next i followed the tutorial for settings.py configuration, i started the server. Then in the admin i created an page (home),…
Luke
  • 1,794
  • 10
  • 43
  • 70
5
votes
1 answer

Django storage S3 - Save File Path only without file using ModelSerializer

I'm using boto3 to upload files to S3 and save their path in the FileField. class SomeFile(models.Model): file = models.FileField(upload_to='some_folder', max_length=400, blank=True, null=True) For the above model the following code works to…
5
votes
3 answers

Processing file uploads before object is saved

I've got a model like this: class Talk(BaseModel): title = models.CharField(max_length=200) mp3 = models.FileField(upload_to = u'talks/', max_length=200) seconds = models.IntegerField(blank = True, null = True) I want to…
Dominic Rodger
  • 97,747
  • 36
  • 197
  • 212
5
votes
4 answers

Upload Image with Django Model Form

I'm having difficulty uploading the following model with model form. I can upload fine in the admin but that's not all that useful for a project that limits admin access. #Models.py class Profile(models.Model): name =…
jmitchel3
  • 391
  • 3
  • 4
  • 17
5
votes
2 answers

What is the correct way to simulate filedata for testing a form?

I'm trying to test a self written FormField AudioFileFormField, which checks if a file is an audiofile before storing it. For that i have overwritten the to_python method. Trying to test this FormField i ran into some difficulties. This is my…
marue
  • 5,588
  • 7
  • 37
  • 65
1
2
3
21 22