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

Django how to upload CSV file using Form to populate postgres database and display all items in browser

Django 3.2.1, Python 3.6, Postgres database EDITED to take into account comments below, thanks! I am writing a small Django app for storing product information. I coded the backend logic for uploading a local csv file using a Custom Management…
2
votes
1 answer

File not in request.FILES but in request.POST I'm using htmx to make post request

I have snippet of inputs that I render to the html page when a condition is met, everythings works appropriately except for the input with type file, I want to upload the files when a change has occured but the file object is not in request.FILES,…
Martins
  • 1,130
  • 10
  • 26
2
votes
1 answer

Use Django models.FileField to read file from memory and discard it before it is written to the directory

How can I read a file using Django's models.FileField, handle the data in memory, and then discard it before django tries to save/write it to my directory. I want to discard the file, but still save the other fields for the model. I now that I can…
juju
  • 884
  • 1
  • 9
  • 31
2
votes
3 answers

Django rest framework large file upload

Is there an easy way to upload large files from the client side to a django rest framework endpoint. In my application, users will be uploading very large files (>4gb). Browsers have a upload limit, here's the chart. My current idea is to upload…
2
votes
2 answers

Media Folder Configuration path not found in django

I am using MYSQL for the database. I want to upload my imagefield files in media folder that I have created in my project. I am getting "empty path didn't exist". settings.py MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL =…
2
votes
1 answer

Is there a better way to write this code so DRY can be maintained?

I have 2 models Tour to save Tour TourImage to save images related to Tour class Tour(models.Model): name = models.CharField(max_length=50) class TourImage(models.Model): tour = models.ForeignKey(Tour, on_delete=models.CASCADE) image…
2
votes
1 answer

File not uploading in Django

I am trying to upload a file in Django to models: class Dealer(models.Model): user = models.OneToOneField(User,on_delete=models.PROTECT) profile = models.OneToOneField(UserProfile,on_delete=models.PROTECT) kyc_verified =…
SAI SANTOSH CHIRAG
  • 2,046
  • 1
  • 10
  • 26
2
votes
1 answer

What is the appropriate way to use a ModelForm field as an argument to upload_to?

I have a ModelForm, where two of the fields are lastname and firstname. I also have a file field for file uploading. As several files are being uploaded by many different people, I would like to group the files into a directory based on their…
Jake Rankin
  • 714
  • 6
  • 22
2
votes
1 answer

django: registering unzipped files on the local disk

[I apologize in advance for the length of this question.] I'm using Django 1.2.3-3+squeeze1 on Debian squeeze. I am writing an application which uploads zip files to disk in a temporary location, unzips them, and then saves the results to…
Faheem Mitha
  • 6,096
  • 7
  • 48
  • 83
2
votes
1 answer

Is this the way to make sure a FileField associated to a model will be deleted?

When I delete a model's instance that has a FileField, the actual file is left in my MEDIA_ROOT folder. To counter this, I'm listening for the post_delete signal, and doing this: def delete_actual_file(sender,**kwargs): import os instance =…
Geo
  • 93,257
  • 117
  • 344
  • 520
2
votes
1 answer

How to allow users to directly download a file stored in my media folder in django?

So I'm building a RESTful API for a "Development Platform" project using Django and want to setup a upload/download feature where the users of the platform can upload various files (Excel files, css files, pdf files, C# scripts, unity packages,…
2
votes
1 answer

Copying files from a saved FileField to an UploadedFile in Django

I need to save files, not from request.FILES, but from another saved record. Here's the code for the model record: class Foo(models.Model) slug = models.SlugField() class FooFile(models.Model): name = models.CharField(max_length=100) …
Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
2
votes
1 answer

django: uploaded images won't be displayed

my uploaded images can't be displayed even though i'm not getting any errors: instead it looks like this and here are my settings and codes: settings.py: STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR,…
Nour Adel
  • 21
  • 6
2
votes
1 answer

How to Upload any kind of file in django 2

I'm New in Django 2. I was trying to upload a file in Django here is my code View.py def addBook(request): checkName = AddBook.objects.filter(title=request.POST.get('title')) if not checkName: bookAdd = AddBook( …
Robot
  • 135
  • 1
  • 1
  • 6
2
votes
1 answer

Django Rest Framework returns bad request when POSTED a file by filepond on React

I have a react app, that uses filepond. Filepond accepts a file, and POSTs it to the server using the following custom header: const filepondServer = { url: `${apiRoot}expenses/receipt_upload`, process: { headers: { Authorization:…
Alex
  • 2,270
  • 3
  • 33
  • 65