Re: Accessing MEDIA_ROOT in templates, always blank/missing
On Thu, 2012-03-22 at 05:25 -0700, Stodge wrote: > No I need MEDIA_ROOT, I want to experiment with: > > > > Thanks in the view: from django.conf import settings and send settings.MEDIA_ROOT to the template or build a templatetag to do the same thing. -- regards Kenneth Gonsalves -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Accessing MEDIA_ROOT in templates, always blank/missing
All good points thanks. I'm only experimenting and learning so this won't hit production. Point taken though. :) On Mar 22, 7:30 am, Tom Evanswrote: > On Thu, Mar 22, 2012 at 12:25 PM, Stodge wrote: > > No I need MEDIA_ROOT, I want to experiment with: > > > > > > Thanks > > MEDIA_ROOT is a file-system location, not a URL-space location, and > should not be exposed in templates. It is nonsense to use media root > as a prefix to the URL-space location of your javascript files. > > Cheers > > Tom -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Accessing MEDIA_ROOT in templates, always blank/missing
On Thu, Mar 22, 2012 at 12:25 PM, Stodgewrote: > No I need MEDIA_ROOT, I want to experiment with: > > > > Thanks > MEDIA_ROOT is a file-system location, not a URL-space location, and should not be exposed in templates. It is nonsense to use media root as a prefix to the URL-space location of your javascript files. Cheers Tom -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Accessing MEDIA_ROOT in templates, always blank/missing
Stoge, you DO need MEDIA_URL in turn to build the URL in which script src is based on. MEDIA_ROOT is the (complete) physical path to the file. Do you want to expose your filesystem? [ ]s Davinir 2012/3/22 Stodge> No I need MEDIA_ROOT, I want to experiment with: > > > > Thanks > > On Mar 22, 7:22 am, kenneth gonsalves wrote: > > On Thu, 2012-03-22 at 05:11 -0700, Stodge wrote: > > > In my template: > > > > > MEDIA_ROOT: {{MEDIA_ROOT}} > > > > > But all I see is: > > > > > MEDIA_ROOT: > > > > > So MEDIA_ROOT is blank or doesn't exist. Did I miss something? > > > > https://docs.djangoproject.com/en/1.0/ref/templates/api/#django-core-... > > > > you need MEDIA_URL > > -- > > regards > > Kenneth Gonsalves > > -- > 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 > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://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-users@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.
Re: Accessing MEDIA_ROOT in templates, always blank/missing
No I need MEDIA_ROOT, I want to experiment with: Thanks On Mar 22, 7:22 am, kenneth gonsalveswrote: > On Thu, 2012-03-22 at 05:11 -0700, Stodge wrote: > > In my template: > > > MEDIA_ROOT: {{MEDIA_ROOT}} > > > But all I see is: > > > MEDIA_ROOT: > > > So MEDIA_ROOT is blank or doesn't exist. Did I miss something? > > https://docs.djangoproject.com/en/1.0/ref/templates/api/#django-core-... > > you need MEDIA_URL > -- > regards > Kenneth Gonsalves -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Accessing MEDIA_ROOT in templates, always blank/missing
On Thu, 2012-03-22 at 05:11 -0700, Stodge wrote: > In my template: > > MEDIA_ROOT: {{MEDIA_ROOT}} > > But all I see is: > > MEDIA_ROOT: > > So MEDIA_ROOT is blank or doesn't exist. Did I miss something? https://docs.djangoproject.com/en/1.0/ref/templates/api/#django-core-context-processors-media you need MEDIA_URL -- regards Kenneth Gonsalves -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Accessing MEDIA_ROOT in templates, always blank/missing
Oh that's surprising; the media context processor only creates MEDIA_URL. On Mar 22, 7:11 am, Stodgewrote: > I'm trying to reference MEDIA_ROOT in my template but it's blank. I > have MEDIA_ROOT defined in settings.py: > > MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), > 'static') > > I have the correct context processor: > > TEMPLATE_CONTEXT_PROCESSOR = ( > 'django.core.context_processors.i18n', > 'django.core.context_processors.auth', > 'django.core.context_processors.media', > ) > > In my template: > > MEDIA_ROOT: {{MEDIA_ROOT}} > > But all I see is: > > MEDIA_ROOT: > > So MEDIA_ROOT is blank or doesn't exist. Did I miss something? This is > Django 1.2.3, thanks. Oh and I realise there is a newer version of > Django out there but I can't upgrade my app... yet.. > > Thanks again -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Accessing MEDIA_ROOT in templates, always blank/missing
I'm trying to reference MEDIA_ROOT in my template but it's blank. I have MEDIA_ROOT defined in settings.py: MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'static') I have the correct context processor: TEMPLATE_CONTEXT_PROCESSOR = ( 'django.core.context_processors.i18n', 'django.core.context_processors.auth', 'django.core.context_processors.media', ) In my template: MEDIA_ROOT: {{MEDIA_ROOT}} But all I see is: MEDIA_ROOT: So MEDIA_ROOT is blank or doesn't exist. Did I miss something? This is Django 1.2.3, thanks. Oh and I realise there is a newer version of Django out there but I can't upgrade my app... yet.. Thanks again -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.