I've implemented this same solution (using custom file storage and the 
"upload_to" parameter) but now cannot get the uploaded files to display 
from my template. I would normally use {{ STATIC_URL }} but, since I've now 
specified a custom location, I'm not sure why my path, which I've 
hard-coded in the template, isn't working...any ideas?

fs = FileSystemStorage(location='/data/www/upload')
def image_location(instance, filename):
    return '/'.join(['thumbnails', str(instance.dataset_id), filename])
class DataModel(models.Model):
    name = models.CharField()
    date = models.DateField(blank=True)  
    image = models.ImageField(storage=fs, upload_to=image_location, blank=True)

template.html

<a href="{% url 'myproj:items' %}">
    <img class="media-object img-thumbnail" src="/data/www/upload/{{ 
datamine.image }}" alt="Data Image Here" height="130" width="130"></a>




On Thursday, September 30, 2010 at 12:45:42 PM UTC-4, Federico Capoano 
wrote:
>
> I wanted to write this post anyway, gives a quick solution to upload 
> files above the public directory and serve the files with django- 
> filetransfers. Hopefully it will be easier to find from search 
> engines. 
>
>
> http://nemesisdesign.net/blog/coding/django-private-file-upload-and-serving/ 
>
>
>
>
> On Sep 30, 10:40 am, Xavier Ordoquy <xordo...@linovia.com> wrote: 
> > Hi, 
> > 
> > To me, it looks like the documentation already gave the answer. 
> > 
> > Regards, 
> > Xavier. 
> > 
> > Le 30 sept. 2010 à 10:37, Federico Capoano a écrit : 
> > 
> > 
> > 
> > > PS: i'll post a solution so other noobs like me will see how to do 
> > > that.. 
> > 
> > > On 30 Set, 10:35, Federico Capoano <nemesis.des...@libero.it> wrote: 
> > >> Yes you're right, I'm trying it out. I'll post a solution when I'm 
> > >> done. 
> > 
> > >> On 30 Set, 10:10, Xavier Ordoquy <xordo...@linovia.com> wrote: 
> > 
> > >>> Well, the documentation already tells you about it:
> http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files... 
> > 
> > >>> Le 30 sept. 2010 à 09:49, Federico Capoano a écrit : 
> > 
> > >>>> Is this not possible? I wonder why Django force to upload files 
> only 
> > >>>> in a certain directory and doesn't allow more flexibility. 
> > 
> > >>>> On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> 
> wrote: 
> > >>>>> Hi everyone, 
> > 
> > >>>>> is it possible to write a custom model filefield that upload files 
> > >>>>> somewhere above the public directory? 
> > 
> > >>>> -- 
> > >>>> You received this message because you are subscribed to the Google 
> Groups "Django users" group. 
> > >>>> To post to this group, send email to django...@googlegroups.com 
> <javascript:>. 
> > >>>> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com <javascript:>. 
> > >>>> For more options, visit this group athttp://
> groups.google.com/group/django-users?hl=en. 
> > 
> > > -- 
> > > You received this message because you are subscribed to the Google 
> Groups "Django users" group. 
> > > To post to this group, send email to django...@googlegroups.com 
> <javascript:>. 
> > > To unsubscribe from this group, send email to 
> django-users...@googlegroups.com <javascript:>. 
> > > For more options, visit this group athttp://
> groups.google.com/group/django-users?hl=en.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/549c35ee-f40c-4b4f-814a-d70c42eff1de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to