Questions tagged [filefield]
299 questions
5
votes
1 answer
django admin uploaded file processing
Here's what I want to do, and I did not find something similar in my search so far.
In my admin page, I have a Filefield in my model. The rest of the fields are all read only.
I want to be able to upload a file and process it immediately and to…

gamadeus
- 251
- 3
- 11
5
votes
1 answer
Filter by file size in Django (FileField)
I have an a model:
class MyModel(models.Model):
file = models.FileField(verbose_name='File', upload_to="files/")
I can get file size in bytes:
size = my_model_instance.file.size
How to filter by file size in Django? Something like that: …

ncopiy
- 1,515
- 14
- 30
5
votes
0 answers
Django: Restrict file type on MULTIPLE uploads
I'm still new to Django and have found some excellent answers on how to restrict the type of file uploaded through Django's FileField. However, these answers deal with the case of a single file upload. I am dealing with the case of a multiple file…

nea2170
- 51
- 2
5
votes
1 answer
page not found django.views.static.serve
first post so be gentle.
I am trying to display a static image in django. I can upload the image to my media directory but when I try to display it I get a nothing. If I copy the url to the browser I get ...
Page not found (404)
Request Method: …

user1738005
- 131
- 1
- 1
- 5
5
votes
2 answers
passing a callback as upload_to to FileField
I have an abstract model class UploadItem for handling uploaded files. I want each subclass to be able to define the upload_to path. For this, i pass a callback to the constructor of FileField.
This is an example:
class UploadItem(models.Model):
…

maroxe
- 2,057
- 4
- 22
- 30
5
votes
3 answers
Change file_field_tag appearance to button appearance
I am working on a Rails project and I want to use file_field_tag but I'd like it looks like a button.
I have this:
with this code:
= file_field_tag 'attachment'
I want something like this:
and I attempted this:
= file_field_tag 'attachment',…

Iván Cortés
- 581
- 1
- 9
- 22
5
votes
2 answers
How to change upload_to parameter of ImageField based on field name in Django?
I would like to upload images to the media root based on the field values given by the Django admin user. Here is the code that I've written and I know that the upload_to parameter is causing the problem. But I don't know how to make it…

MiniGunnR
- 5,590
- 8
- 42
- 66
5
votes
1 answer
Django FileField storage option
I have this model:
class UserProfile(models.Model):
#..........
photo = models.ImageField(upload_to = get_upload_file_name,
storage = OverwriteStorage(),
blank = True, null = True,
…

Mihai Zamfir
- 2,167
- 4
- 22
- 37
5
votes
3 answers
Rails 4 add file_field for attachment upload to existing form and controller
I'm super new to rails. Been learning a few weeks now. Please excuse my idiocy. I cannot get my file I've selected to upload.
I'm using Rails 4.0.0.
I am working on my first application, and I started by following the rails guide for the blog…

kyle
- 568
- 2
- 10
- 26
4
votes
2 answers
How can I rename files with a python script?
On my plone site I have hundreds of files (pdf, doc, ...) in filefield of archetypes objects. Something went wrong during importation and all the filenames are missing. The problem is that when somebody wants to open the file, since the extension…

user1035648
- 493
- 4
- 7
4
votes
1 answer
Removing default file names in Django-Storages S3
I'm using django-storages with amazon S3, and uploading image files with:
models.ImageField(upload_to="img=%Y-%m-%d", max_length=256, blank=True, null=True)
When the files are uploaded to S3 however, it has the original file name attached at the…

ahalbert
- 474
- 1
- 6
- 15
4
votes
2 answers
How to add a new instance of Django model with FileField by ModelForm?
I'm a Django beginner. I think my problem is trivial but I can't solve it.
I have a model named Document with one FileField:
class Document(models.Model):
file = models.FileField(upload_to="documents")
created =…

marrog
- 41
- 1
- 3
4
votes
2 answers
Django dynamic models.FileField Storage
I have a model like this:
class Person(models.Model):
name = models.Charfield(max_length¶=30)
photo = models.FileField(upload_to='uploads/')
Is there any way to dynamically change the Storage class of photo field based on the value of the…

Hasan Ramezani
- 5,004
- 24
- 30
4
votes
2 answers
Rails file_field tag passing only String file name to controller
My file_field tag is only passing the file name, not the file itself to the controller.
In my User model:
mount_uploader :avatar, AvatarUploader
validate :avatar_size
...
def avatar_size
errors.add :avatar, "should be less than 5MB" if avatar.size…

Alex Coats
- 115
- 2
- 16