Hi all:
I am just getting started with Django and could really use some
initial help. My first hurdle is this: I would like to have the act of
choosing a file automatically propagate several of fields of my model.
Bellow is an example of the model of interest here:
##models.py
from django.db import models
class Media(models.Model):
media_name = models.CharField('name', max_length=100)
media_size = models.IntegerField('file size in bytes')
media_hash = models.CharField('SHA1 hash', max_length=40)
media_loc = models.FileField(upload_to='test',
verbose_name="media")
is_active = models.BooleanField('is active?')
add_date = models.DateTimeField('date added', auto_now_add=True)
class Meta:
verbose_name = "Media File"
def __unicode__(self):
return self.media_name
return self.media_hash
The desired behavior is to be able to select a file to upload and have
it validated. Then, either during the validation process or
afterwards, I would like to populate the fields of my model with data
that is detected from the file. Data such as: the file's size, the
file name and an SHA1 hash of the file.
Just to restate, I would really like to be able to do this from within
the provided admin interface. I am not able to figure out how to even
validate this file from within the admin, let alone perform additional
operations on it.
Thanks,
~Vincent
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---