Hi,

I have an Attachment model that has a mime_type field. Here's my basic
model:

class Attachment(models.Model):
    id = models.AutoField(primary_key=True)
    comment=models.ForeignKey(Comment, null=True)
    file = models.FileField('File', upload_to=get_attachments_path)
    filename = models.CharField(max_length=128)
    mime_type = models.CharField(max_length=128)
    size = models.IntegerField()

I am able to upload an image just fine and it ends up in a location
such as:

http://172.28.180.51:8080/site_media/attachments/193/3256/PLAY.pptx

In my html that I'm generating I just have the user clicking on
something like this:

<a href="/site_media/attachments/193/3256/PLAY.pptx"
target="_blank">PLAY.pptx</a>

Although I have the mime_type in the model, I am not doing anything
with the mime_type, so obviously it is not getting passed through in
the response.  As a result, the Content-Type when running with Apache
is text/plain.  (Oddly when running with run_server, the Content-Type
is served up as  application/octet-stream.)  In any case, the real
mime-type is not getting served up because I'm not providing it.

So my question is - how does one normally do this?  Do I have to
create a views.py function which returns an HttpResponse that returns
my attachment and the mimetype together?  IE, as described in the doc
where it shows

>>> response = HttpResponse(my_data, mimetype='application/vnd.ms-excel')
>>> response['Content-Disposition'] = 'attachment; filename=foo.xls'

I just was wondering if this is the appropriate solution, or if there
is anything I'm missing.

Thanks for any pointers,

Margie

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to