Questions tagged [filefield]
299 questions
0
votes
1 answer
How to save a ByteArray from Flex into a FileField in Django
I have some audio data in a byte array in a Flex app that I would like to save to my model in Django. I assume I would use a FileField, but I can't seem to get it to work. (My project is set up like this.) I've tried looking at this sample code for…

Sauce McBoss
- 6,567
- 3
- 20
- 22
0
votes
1 answer
Django ImageFieldFile set to . How to change it to blank/empty, like other entries in the table?
I have a FileField in a Django Model. Some entries in this FileField are set to .
The rest of the Model table are blank or actual images. I need to clean this table so that these erroraneous entries are also changed to blank,…

Vikramark
- 137
- 13
0
votes
1 answer
How to properly display images to html template in Django framework?
I've been trying for a day to try to get the images that are saved to the media folder to display in my template file, but to no avail. The images are uploaded to the media/images folder, but I can't figure out how to display them. I can't figure…

Vishnu
- 21
- 5
0
votes
1 answer
How to override filefield in views.py?
I have view to document edit:
@login_required
def document_edit(request, doc_id):
try:
doc = Document.objects.get(id=doc_id)
except Document.DoesNotExist:
raise Http404
form = DocumentForm(instance=doc)
if…

marrog
- 1
- 1
0
votes
1 answer
django - How to upload file to the folder in filefield
i am saving a form with a filefield, and saying upload_to to a user_path from the userprofile. I do not know how to write the view for the form
models.py
def nice_user_folder_upload(instance, filename):
extension = filename.split(".")[-1]
…

user11603936
- 69
- 1
- 7
0
votes
0 answers
How to save the link of the file uploaded in the database and the actual file in a specific folder in django
I have a form with an upload option (filefeild). The file uploaded is saved directly in the databse. I need to store the file in a specific folder and the link to the file on the database
For now the uploaded file is directly stored in the database…

user11603936
- 69
- 1
- 7
0
votes
0 answers
How to get the path to a FieldField considering the upload_to() function
I am making an app with Django and I am working with an ImageField. I have this function as the upload_to argument:
def group_directory_path(instance, filename):
# file will be uploaded to MEDIA_ROOT/group_/time/
return…

Vincent Quirion
- 389
- 2
- 4
- 16
0
votes
0 answers
Is it better to put filefields of all models in another model or not?
Which of the choices below is better regarding the database design and other factors.
Option 1)
class Profile(Model):
name = CharField(...)
family_name = CharField(...)
passport_number = CharField(...)
ielts = ForeignKey(Ielts)
…

Amin Ba
- 1,603
- 1
- 13
- 38
0
votes
1 answer
Error in saving an array of images sent from front-end to Django backend
I am facing a problem while trying to send an array of images from the frontend(ReactJS) to the backend(Django). An object instance is not being saved at the backend because of the mandatory ArrayField in the Django Model. I am using PostgreSQL with…

Eeshan S Jaiswal
- 3
- 4
0
votes
1 answer
Why I can't update my one-to-one model's FileField in Django?
In order to add more features to the default model, I employed one-to-one filed in Django. Then I want to customize my update/edit Userprofile page.
I rewrite the update form like this :
{% load static %}
...

Jiacheng Liu
- 31
- 3
0
votes
0 answers
How do i use the less than or greater than signs inside html in python django
Hi am struggling using the greater than sign inside the html template. am using python 3.7.2 and django 1.8.6
I cant execute this code here gives an error
{% extends "base.html" %}
{% block Content %}
Tags
{% for instance in…
cipher
- 373
- 7
- 20
0
votes
1 answer
UnicodeDecodeError Error charmap' codec can't decode byte 0x81 in position 250:
class ProductDownloadlView(MultiSlugMixin,DetailView):
model=Product
def get(self,request,*args,**kwargs):
obj=self.get_object()
filepath = os.path.join(settings.PROTECTED_ROOT,obj.media.path)
guessed_type =…

cipher
- 373
- 7
- 20
0
votes
1 answer
Django REST framework FileField PUT Testcase
I have a model that contains a FileField which may not be blank. When creating tests for this model, I've run into the problem that I get errors when testing with PUT, while the exact same thing works when doing a POST.
As views I'm simply using…

Nycrea
- 1
- 1
0
votes
1 answer
Django, viewing uploaded files and videos
I would like to be able to view my uploaded files. I really have a poor grasp of what I am doing.
views.py
def upload_file(request):
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if…

h.pylori
- 53
- 5
0
votes
0 answers
How can I know the length of filepath in FileField in Django?
The website I was working on involves uploading of some files and downloading them. But I have to display the path where an uploaded file is stored.
So a model FileField named 'bulk_add' is added in models.py to store filepath like this:
bulk_add =…

Light Yagami
- 961
- 1
- 9
- 29