Questions tagged [filefield]
299 questions
3
votes
1 answer
Hooking between file uploaded and before model saved
I'm new to django and try to realize an project that allows the user to upload a file, parses it and enters the contained information into the same model:
class Track(models.Model):
Gpxfile = models.FileField("GPS XML",…

MaM
- 2,043
- 10
- 20
3
votes
1 answer
Validating data in Django ModelForm
And i have a simple modelform for Package
from models import Package
from django import forms
class PackageForm(forms.ModelForm):
class Meta:
model= Package
fields= ['name', 'version', 'url', 'description', 'arch', 'dependancies',…

PirosB3
- 1,961
- 1
- 17
- 21
3
votes
1 answer
Django python-magic identify ppt,docx,word uploaded file as 'application/zip'
I am trying to identify the file type of the files uploaded, after searching, I plan to use the python-magic to check the mime types of a file.
The FileField is used in my models, a ModelForm is used to help save the files.
After all the files have…

Mona
- 1,425
- 6
- 21
- 31
3
votes
1 answer
Django - UploadedFile.content_type checks the header of the file uploaded or just the extension?
I read from the following django document
UploadedFile.content_type
The content-type header uploaded with the
file (e.g. text/plain or application/pdf). Like any data supplied by
the user, you shouldn’t trust that the uploaded file is actually…

Mona
- 1,425
- 6
- 21
- 31
3
votes
2 answers
upload_to attribute seems not to be used while saving a FileField
I can't get my FileField's url set to what I want.
My model is defined by
class MyModel(models.Model):
pdf_file = models.FileField(upload_to="reports", null=True, blank=True)
# more stuff
and I create an instance using:
myModel =…

jul
- 36,404
- 64
- 191
- 318
3
votes
1 answer
Django ImageField / FileField custom upload_to function, and security
I have part of a model defined like this:
logo_image = models.ImageField(upload_to=lambda i, fn: "logo_%s"%(fn), height_field="logo_image_height", width_field="logo_image_width")
and had a question about the upload_to function.
According to…

The_OP
- 667
- 1
- 8
- 11
3
votes
1 answer
Rails: set file to file_field
Having the following form:
= form_for company, html: { multipart: true } do |form|
= form.label :logo, 'Upload Image'
= form.file_field :logo
I want to set file_field value to another user uploaded image (have the object of…

tiktak
- 1,801
- 2
- 26
- 46
3
votes
0 answers
Trying to validate Filefield using wtforms
I am trying to capture the filename of an uploaded file via a wtforms FileField
in my validator
def checkfile(form,field):
print form
print field
the 'print forms' statement shows: forms.ticket.TicketForm object at…

user1669199
- 41
- 4
2
votes
1 answer
Renaming django FileField files
Some additional features were added to a django application, and as a result the upload_to function also expanded.
Since django by default stores filenames in the database, and files on disk, no harm has been done - new files are named using a new…

qdot
- 6,195
- 5
- 44
- 95
2
votes
0 answers
Wrong path return by a FileField in Django
I've got a FileField with the following upload_to option:
def get_file_path(instance, filename):
return os.path.join('rapports/rapports_journaliers', filename)
class ListPCA(models.Model):
pdf_file =…

jul
- 36,404
- 64
- 191
- 318
2
votes
1 answer
Plone 4 - Get url of a file in a plone.app.blob.field.FileField
I have a custom content type with 3 FileFields (plone.app.blob.field.FileField) and I want to get their url's, so i can put them on my custom view and people will be able to download these files.
However, when using Clouseau to test and debug, I…

Lucas Infante
- 798
- 6
- 21
2
votes
1 answer
button_to for file_field?
I feel pretty dumb for asking this, but is it possible to just use a button_to for a file upload as part of a form? I want to create a custom "upload file" button. I would just use the good ol' file_field, but apparently you can't customize that…

Oakland510
- 1,073
- 2
- 12
- 20
2
votes
1 answer
reindexObject fails during FileField to BlobField migration in Plone 4.0.7
I'm trying to migrate from plone 3.3.5 to plone 4.0.7 and I'm stuck on a step that converts all the FileFields to BlobFields.
Plone upgrade script successfully converts all native FileFields but I have several custom AT-based classes which have to…

Alex Volkov
- 2,812
- 23
- 27
2
votes
1 answer
Saving a ZipFile to FileField in Django
I have the following model in Django:
class AksOrder(models.Model):
zip_file = models.FileField(upload_to='aks_zips/%M/%S/', blank=True)
and in my views I have in essential these functions:
def gen_zip(pk, name, vars):
zipObj =…

zeus
- 117
- 7
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