Questions tagged [filefield]
299 questions
11
votes
1 answer
customising the look of f.file.field in rails
<%= f.file_field :photo %>
Currently this just looks like a button, how can I add some css and customise the look (e.g dimensions background etc) of this button? Thanks

user852974
- 2,242
- 10
- 41
- 65
11
votes
2 answers
Django: Save an uploaded file to a FileField
I feel a little stupid for having to ask this… But I can't seem find it documented anywhere.
If I've got a Model with FileField, how can I stuff an uploaded FILE into that FileField?
For example, I'd like to do something like this:
class…

David Wolever
- 148,955
- 89
- 346
- 502
10
votes
3 answers
Django FileField default file
I have a model which contains FileField as below
class Employer(models.Model):
logo = models.FileField(storage=FileSystemStorage(location=settings.MEDIA_ROOT), upload_to='logos')
The question is how can I add a default file like "{{…

brsbilgic
- 11,613
- 16
- 64
- 94
9
votes
2 answers
Django: generate a CSV file and store it into FileField
In my Django View file, I need to generate a CSV file from a list of tuples and store the CSV file into the FileField of my model.
class Bill(models.Model):
billId = models.IntegerField()
bill = models.FileField(upload_to='bills')
I…

BAE
- 8,550
- 22
- 88
- 171
8
votes
2 answers
How to get the files uploaded in InMemoryUploadedFile django
I am developing an application in django 2.1 in which I must upload an undetermined number of audios through a modal and then pass the information to the view from which the modal is launched.
However, these audios should not be stored in the…

trok brk
- 159
- 2
- 3
- 13
7
votes
2 answers
How to prevent Django from changing file name when a file with that name already exists?
In my case I allow user to upload an avatar picture and use user_id as filename, simply. So there will be 1.jpg, 2.jpg, etc.
However I found if I upload a new avatar for some account that already has one uploaded, let's say user #10, the new file…

x1a0
- 9,984
- 5
- 22
- 30
7
votes
1 answer
how to find height and width of image for FileField Django
How to find height and width of image if our model is defined as follow
class MModel:
document = FileField()
format_type = CharField()
and image is saved in document then how we can find height and width of a document if it is image ?

Paras Meena
- 191
- 4
- 11
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
2 answers
Admin FileField current url incorrect
In the Django admin, wherever I have a FileField, there is a "currently" box on the edit page, with a hyperlink to the current file. However, this link is appended to the current page url, and therefore results in a 404 as there is no such page as,…

Rowan Ingram
- 201
- 2
- 9
7
votes
2 answers
How to get the link of the file in a FileField?
how can I get the link of a FileField? I tried the url field, but it gives the file path:
In [7]: myobject.myfilefield.path
Out[7]: u'/home/xxxx/media/files/reference/1342188147.zip'
In [8]: myobject.myfilefield.url
Out[8]:…

jul
- 36,404
- 64
- 191
- 318
6
votes
1 answer
Copy a file in Ruby on Rails
I would like to copy a file from my computer to another specified path. The file has to be chosen by the user with a file_field and the destination is already hard-coded. How can I do that ? Thank you.

TW147
- 561
- 2
- 7
- 20
6
votes
2 answers
django get_available_name() got an unexpected keyword argument 'max_length'
I want to override files with the my django Model. So if I upload 'one' and later upload 'two', 'two' should override 'one' (on the file system). But I get an error.
This is my model:
class StudentAssignment(models.Model):
file0 =…

Max
- 1,368
- 4
- 18
- 43
6
votes
2 answers
Django - update a model won't delete the old FileField
I am implementing an application with django, which has a model with a FileField:
class Slideshow(models.Model):
name = models.CharField(max_length=30,unique=True)
thumbnail =…

Maveric
- 159
- 2
- 11
6
votes
3 answers
Extjs - upload file using filefield
My extjs code like http://www.objis.com/formationextjs/lib/extjs-4.0.0/docs/api/Ext.form.field.File.html
Ext.create('Ext.form.Panel', {
title: 'Upload a Photo',
width: 400,
bodyPadding: 10,
frame: true,
renderTo: Ext.getBody(), …

DeLe
- 2,442
- 19
- 88
- 133
6
votes
2 answers
Django models.FileField - store only the file name not any paths or folder references
I'm using Django's Admin site to manage some data - but not building a webapp. I need the file upload field to store only the file name in the database.
Right now I can get absolute paths like:
/Users/me/uploads/file.png
Or using the upload_to…

gngrwzrd
- 5,902
- 4
- 43
- 56