And you don't even need to import os there (oops)

On Wed, Apr 23, 2008 at 1:53 PM, Michael <[EMAIL PROTECTED]> wrote:

> Add this to your model:
>
> def get_FILE_url(self):
>      import os
>      from django.conf import settings
>      return '/' + str(self.FILE).split(settings.MEDIA_ROOT)[-1]
>
> tadah you have your method without rewriting django fields
>
>
>
> On Wed, Apr 23, 2008 at 1:22 PM, [EMAIL PROTECTED] <
> [EMAIL PROTECTED]> wrote:
>
> >
> > You could either do that, or just add a method to your model, both
> > would employ the same logic, it's just a question of reusable vs. time
> > to implement.
> >
> > On Apr 23, 12:17 pm, skam <[EMAIL PROTECTED]> wrote:
> > > Okay, that's a valid reason, but I really want these files to be into
> > > MEDIA_ROOT and get file's absolute url using a get_FIELD_url method.
> > > Is subclassing the field and implementing contribute_to_class method a
> > > good idea?
> > >
> > > On 23 Apr, 18:47, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > wrote:
> > >
> > > > FilePathField can refer to any location on your system, there is no
> > > > reason to believe it is below the MEDIA_ROOT.
> > >
> > >
> > > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to