Hi all,

I've been a casual user of Django for years, but recently have need to make 
a new field based on FileField. I decided to take a look at ImageField, 
since it is very similar to what I'm doing.

Specifically I'm looking at using mutagen (python-mutagen) to get 
information about audio files. Mutagen can tell me the bitrate, duration 
and then tags for the audio.

That's quite similar to how ImageField uses PIL underneith, so all's good 
there.

But in my investigation, I'm coming across some code I am having difficulty 
following.

Both the ImageField itself and the ImageFieldDescriptor class call a method 
on ImageField called update_dimension_fields.

The docstring says that it updates the field's width and height attributes, 
but even after reading the code many times, I am not seeing where the 
height and width are retrieved from the image itself, rather than either 
being passed in values or values already in the database.

Another question here is in regards to tags. Similar to image's exif data, 
these audio files can contain tags, and in the case of many formats (such 
as Ogg Vorbis) this tag data can be relatively arbitrary. It would seem 
then that I'm stuck with three ugly options:

1. I can make an explicit reference in my new OggVorbisFileField for each 
field that the user may care about in their model (ie title, artist) 
similar to how it works with ImageField's height and width

2. Instead of referencing each field, have an ugly "tags" field that 
contains something like a pickle'd dictionary of key/value pairs

3. Make an arbitrary set of key/value pairs in the DB through a many/many 
relationship for each of the tags

The fields that I care about (title, artist, etc.) will already be stored 
in my model that will contain the new OggVorbisField, so I'm wondering if 
there's a best practice here that I should try to follow.

Thanks all,

- Serge

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f5469b66-2227-4c5b-8422-b467965e376b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to