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
1 answer

Django view for storing files from request

I'm building a django application that will be operated via desktop application. Key feature for now is sending/storing files. Basically I need a django view with URL on which I can send files with POST and this view will store the files. Currently…
mastodon
  • 497
  • 5
  • 11
  • 22
0
votes
1 answer

Set ``upload_to`` function of a field in a foreign key

I have the following models structure: class BaseMovie(models.Model): movie = models.FileField('Movie') width = models.IntegerField('Width') height = models.IntegerField('Height') duration = models.FloatField('Duration') class…
mimo
  • 2,469
  • 2
  • 28
  • 49
0
votes
1 answer

Need an Example of Django big File upload with upload file handler method

In one of my django project I am trying to upload files. Files can be video files and can be big as 20 MB. I am trying to upload it with celery and upload_file_handler method given in django docs. What I did is it. class MyVideo(models.Model): …
user2534069
  • 3
  • 1
  • 3
0
votes
3 answers

why do I get "FileNotFoundError" when doing fileupload with Django?

I am writing a file upload page with Django/Python. I get this error: FileNotFoundError: [Errno 2] No such file or directory: '48.png'. Here is the relevant part of the view, which handles the upload: `if request.method == 'POST': form…
Old_Mortality
  • 519
  • 1
  • 4
  • 14
0
votes
1 answer

Why is request.FILES not working?

When I try to use request.Files I get the following error WSGIRequest' object has no attribute 'Files' heres my views.py from django.contrib import messages from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from…
losee
  • 2,190
  • 3
  • 29
  • 55
0
votes
1 answer

Django: Saving file to specific location

I am trying to find a way to save a file on a specific location each time its uploaded. Here are the models that I am working with. class App(models.Model): name = models.CharField(max_length=20) description =…
waweru
  • 1,024
  • 14
  • 16
0
votes
2 answers

Is this the wrong logic for image uploading with django? form.is_valid = false

I am really new to django, and I'm not sure I completely understand how forms work or how to use them. I've been looking through a couple tutorials concering file-uploading, but there are a lot of different ways it seems. I'll just include the whole…
Patidati
  • 1,048
  • 2
  • 12
  • 19
0
votes
0 answers

DOS/Unix/Mac text type in django filefield

I have a django form which accepts a text file, which I process directly in a view method. It has worked fine, until someone recently tried uploading a text file created on a Mac, which has different newlines (\r), and the function treated the…
askvictor
  • 3,621
  • 4
  • 32
  • 45
0
votes
1 answer

Asserting for presence of an uploaded file in Django

Say I have a model containing a FileField and I have just created an object, and hence have a file stored to a particular location. How would I assert the file is stored in there? For my case I have MEDIA_ROOT='/path/to/my/files/' in my settings.py…
Afzal S.H.
  • 1,084
  • 2
  • 14
  • 27
0
votes
0 answers

Django Custom Model Field clean() is not called when I inherit the class containing the custom field in another class.

I have 2 model classes class A(models.Model) in app1 and class B(A) in app2 as follows: #app1/models.py class CustomImageField(models.ImageField): """ Same as ImageField, but you can specify: * max_upload_size - a number indicating…
attaboyabhipro
  • 1,450
  • 1
  • 17
  • 33
0
votes
2 answers

django file upload - image deleted when edit template updated

I am using django to allow a user to upload images along with text to describe the image title. The user should be able to edit the image title and change the image file using the edit template. This does work - to some degree. I can display the…
user3354539
  • 1,245
  • 5
  • 21
  • 40
0
votes
1 answer

Django FileField passing the files

OK, I have a model for TemporaryFile and the final file model (File) they have different storage functions (destinations). I'm saving the first model and after some time I need to pass the file to the second model, so that it saves the file its way.…
wswld
  • 1,218
  • 15
  • 32
0
votes
0 answers

Django form with fileupload

I'm hitting my head against the wall with uploading a file through a form. When uploading through the admin everything works fine. When using a modelform it reloads the form with the filefield blank and the error message "This field is…
0
votes
1 answer

cannot upload image in django modelform

hi i made a form in django which has an imagefield but i am unable to upload images my views.py- def fill(request): global firstname, lastname, email, roomnumber, hostel, hometown, homestate, gender, year, branch, age, dateofbirth, formdata,…
aquaman
  • 1,523
  • 5
  • 20
  • 39
0
votes
1 answer

Django email attachment filetype limit

How can I limit the type of files of the email attachments sent by my contact form to Doc, Docx, PDF?
Harry
  • 13,091
  • 29
  • 107
  • 167