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
2 answers

Django - updating database with an excel file is causing an error when primary key already exists

Note in my model contact_email is my primary key for the Contact model I have an html page and form where users can upload an excel file to upload their contacts to the database. If contact_email has not been uploaded previously, everything works…
Padoga
  • 495
  • 3
  • 18
0
votes
2 answers

Django : Form Successful but image not uploaded

MODELS.PY class Campaign(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) campaign_image = models.ImageField(default="profilepic.jpg",upload_to="campaign_pictures") FORMS.PY class RaiseFundsFrom3(forms.ModelForm): …
Irfan Harun
  • 979
  • 2
  • 16
  • 37
0
votes
1 answer

Django: form not valid

I am trying to perform a file upload. I am using Angularjs as front-end and Django as backend. I am able to upload a file successfully as shown in my logs. However, when the file data is passed to Django, I don't know why the form is not valid. This…
0
votes
1 answer

Django: How to create file directory, upload file into that directory, access that file for calculation, and store it for download?

I'm making a django project that lets specific users to: * first, upload a file with specified file-type; * second, use that file to perform some calculations; and * third, provide a derivative file for download. The user can then view the list of…
Semb
  • 156
  • 2
  • 20
0
votes
1 answer

How to correctly to download file with django requests

I am running a Django app where I can upload files. Now I want to download the files using requests. I was trying to create a view where the file is downloaded, so I can then make a call with requests. But it doesn't quite work My model: class…
0
votes
1 answer

How to manually fill a form field after being submitted using a value passed to the URL in Django?

I have this form where the user has to upload a file(receipt) and then connect that file with a foreign key. I have created a simple form which takes the file, and it is working fine too. But, I have to save that file in the database, along with a…
Rohit Kumar
  • 684
  • 2
  • 17
  • 39
0
votes
1 answer

How to upload image file in django related to a perticular user only

I'm trying to upload a file in Django such that uploaded file is linked to a foreign key. i.e. if I upload a file then in the database it should reflect that with which database subject it is related to This is my views.py file: def pod_upload…
0
votes
1 answer

Copy a File from one Model's FileField to another Model's FileField without reading it

Let's say I have a model somewhat like this - class Test(models.Model): some_file=FileField(upload_to='test_directory') class TestTransfer(models.Model): transferred_file=FileField(upload_to='transfer_directory') Now, I have already tried…
0
votes
1 answer

Load image from django rest in React JS

Trying to get image stored in django model in react js Firstly I have upload image from react to django rest and saved it in a model.It saved like this "/media/project_mainimage/newimage.jpg".But now I want to get this image from django to react and…
0
votes
2 answers

Making the file_names unique with timestamp in django image upoads

Intro: I have a small piece of code that takes any image that is being added and makes it smaller and saves it. I am using a external library called Filepond for this. The Issue: If 2 users add same names to their images(different images). The…
0
votes
0 answers

Validate file size for multiple files uploads

I have django inline to uploads files, so it can upload multiple files at same time. (one file for a one file field) And my nginx limits upload size to 20MB. Now I want to check the total size of all files, and give proper error massage if it…
mhs
  • 1,012
  • 2
  • 14
  • 35
0
votes
3 answers

Unable to read Django FileField?

I am trying to read from Django Filefield, as can be seen in my Django Model: import os import win32api from django.db import models from custom.storage import AzureMediaStorage as AMS class File(models.Model): ''' File model ''' …
Virat
  • 129
  • 4
  • 20
0
votes
1 answer

Django SuspiciousFileOperation

I have a model that contains a FileField: class Foo(models.Model): fileobj = models.FileField(upload_to="bar/baz") I am generating a file, and saving it in /tmp/ as part of the save method. This file then needs to be set as the "fileobj" of the…
Alex
  • 2,270
  • 3
  • 33
  • 65
0
votes
2 answers

Error when testing the view with a file upload

I would like to test a file upload from my view with the following function: def test_post(self): with open("path/to/myfile/test_file.txt") as file: post_data = { 'description': "Some important file", 'file':…
Daniel Holmes
  • 1,952
  • 2
  • 17
  • 28
0
votes
1 answer

Django assigning a remote file to a FileField without download and reuploading

I'm using django-storages as my default file storage. I have a script that uploads videos directly from the client to google cloud storage. Is there any way to associate this file to a FileField without downloading and reuploading the file. Thank…