Hi, I've got a model defined like so:
"""
from django.conf import settings
from django.db import models
from django.core.files.storage import FileSystemStorage

class ReportStorage(FileSystemStorage):
    @staticmethod
    def filepath(instance, filename):
        subdir = '/'.join((instance.account.client.username,
instance.account.number))
        filename = '%s.pdf' % instance.slug
        return '/'.join((subdir, filename))

report_storage = ReportStorage(location='%s/reports' %
settings.MEDIA_ROOT,
                                    base_url=settings.MEDIA_URL
+'reports')
class Report(models.Model):
    content = models.FileField(storage=report_storage,
upload_to=report_storage.filepath)
"""

However, the urls aren't being generated as expected.  Here's an
interactive session:
"""
In [1]: from apps.userhomes.models import Report

In [2]: foo = Report.objects.get(id=1)

In [3]: foo.content.url
Out[3]: u'/media/test1/111/2008q3.pdf'

In [4]: foo.content.storage.base_url
Out[4]: '/media/reports'
"""

I'd expect that 3rd output to be  u'/media/reports/
test1/111/2008q3.pdf' instead; FileSystemStorage.url() specifies that
the base_url should be used.

Can anybody give me a clue what's going on here?

TIA

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to