Saturday, June 30, 2012

Re: Where I am wrong in loading static files ?



On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
On 22-6-2012 15:53, surya wrote:
> This is my project folder hierarchy:
>
> project \
>            project \
>                       __init__.py
>                       settings.py
>                       urls.py
>                       views.py
>                       ... etc
>            templates \
>                            css \
>                                 index_css.css
>
>                            media \
>                                  logo.png
>
>                            templates \
>                                      home.html
>            manage.py
>
>
> So, these are the settings I made in "settings.py"
>
> currDir = os.path.dirname(__file__)
> templateDir_media =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "media")
> templateDir_css =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css")
>
> STATICFILES_DIRS = (
>                     templateDir_media,
>                     templateDir_css,
>                     "d:/code/projects-dev/readdme/"
> )
> ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT
>
> The HTML source file contains:
>
> Image URL:  src="../media/logo.png"
> CSS URL : href="../css/twoColFixLtHdr.css"

You're not using staticfiles, because they will always result in
absolute path references. Try starting with the documentation and let us
know what you don't understand about it:
https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/

--
Melvyn Sopacua



Thanks Melvyn.. 

I could display photos on the template. But there is a problem.. 

when I am using collectstatic command, it is collecting all files and storing in project folder.

I mean, 

<project>/
               (static files)
               manage.py
               <project>/

Is there any way to avoid it??

Another thing is, the files are not working with I am switching off debug mode (DEBUG = False). I searched on it and found that I need to use my own webserver for that. So, I'd like to use Apache Http but don't know how to configure it!! 

Can you help me on it?

 

On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
On 22-6-2012 15:53, surya wrote:
> This is my project folder hierarchy:
>
> project \
>            project \
>                       __init__.py
>                       settings.py
>                       urls.py
>                       views.py
>                       ... etc
>            templates \
>                            css \
>                                 index_css.css
>
>                            media \
>                                  logo.png
>
>                            templates \
>                                      home.html
>            manage.py
>
>
> So, these are the settings I made in "settings.py"
>
> currDir = os.path.dirname(__file__)
> templateDir_media =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "media")
> templateDir_css =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css")
>
> STATICFILES_DIRS = (
>                     templateDir_media,
>                     templateDir_css,
>                     "d:/code/projects-dev/readdme/"
> )
> ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT
>
> The HTML source file contains:
>
> Image URL:  src="../media/logo.png"
> CSS URL : href="../css/twoColFixLtHdr.css"

You're not using staticfiles, because they will always result in
absolute path references. Try starting with the documentation and let us
know what you don't understand about it:
https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/

--
Melvyn Sopacua



On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
On 22-6-2012 15:53, surya wrote:
> This is my project folder hierarchy:
>
> project \
>            project \
>                       __init__.py
>                       settings.py
>                       urls.py
>                       views.py
>                       ... etc
>            templates \
>                            css \
>                                 index_css.css
>
>                            media \
>                                  logo.png
>
>                            templates \
>                                      home.html
>            manage.py
>
>
> So, these are the settings I made in "settings.py"
>
> currDir = os.path.dirname(__file__)
> templateDir_media =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "media")
> templateDir_css =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css")
>
> STATICFILES_DIRS = (
>                     templateDir_media,
>                     templateDir_css,
>                     "d:/code/projects-dev/readdme/"
> )
> ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT
>
> The HTML source file contains:
>
> Image URL:  src="../media/logo.png"
> CSS URL : href="../css/twoColFixLtHdr.css"

You're not using staticfiles, because they will always result in
absolute path references. Try starting with the documentation and let us
know what you don't understand about it:
https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/

--
Melvyn Sopacua



On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
On 22-6-2012 15:53, surya wrote:
> This is my project folder hierarchy:
>
> project \
>            project \
>                       __init__.py
>                       settings.py
>                       urls.py
>                       views.py
>                       ... etc
>            templates \
>                            css \
>                                 index_css.css
>
>                            media \
>                                  logo.png
>
>                            templates \
>                                      home.html
>            manage.py
>
>
> So, these are the settings I made in "settings.py"
>
> currDir = os.path.dirname(__file__)
> templateDir_media =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "media")
> templateDir_css =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css")
>
> STATICFILES_DIRS = (
>                     templateDir_media,
>                     templateDir_css,
>                     "d:/code/projects-dev/readdme/"
> )
> ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT
>
> The HTML source file contains:
>
> Image URL:  src="../media/logo.png"
> CSS URL : href="../css/twoColFixLtHdr.css"

You're not using staticfiles, because they will always result in
absolute path references. Try starting with the documentation and let us
know what you don't understand about it:
https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/

--
Melvyn Sopacua



On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
On 22-6-2012 15:53, surya wrote:
> This is my project folder hierarchy:
>
> project \
>            project \
>                       __init__.py
>                       settings.py
>                       urls.py
>                       views.py
>                       ... etc
>            templates \
>                            css \
>                                 index_css.css
>
>                            media \
>                                  logo.png
>
>                            templates \
>                                      home.html
>            manage.py
>
>
> So, these are the settings I made in "settings.py"
>
> currDir = os.path.dirname(__file__)
> templateDir_media =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "media")
> templateDir_css =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css")
>
> STATICFILES_DIRS = (
>                     templateDir_media,
>                     templateDir_css,
>                     "d:/code/projects-dev/readdme/"
> )
> ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT
>
> The HTML source file contains:
>
> Image URL:  src="../media/logo.png"
> CSS URL : href="../css/twoColFixLtHdr.css"

You're not using staticfiles, because they will always result in
absolute path references. Try starting with the documentation and let us
know what you don't understand about it:
https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/

--
Melvyn Sopacua



On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
On 22-6-2012 15:53, surya wrote:
> This is my project folder hierarchy:
>
> project \
>            project \
>                       __init__.py
>                       settings.py
>                       urls.py
>                       views.py
>                       ... etc
>            templates \
>                            css \
>                                 index_css.css
>
>                            media \
>                                  logo.png
>
>                            templates \
>                                      home.html
>            manage.py
>
>
> So, these are the settings I made in "settings.py"
>
> currDir = os.path.dirname(__file__)
> templateDir_media =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "media")
> templateDir_css =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css")
>
> STATICFILES_DIRS = (
>                     templateDir_media,
>                     templateDir_css,
>                     "d:/code/projects-dev/readdme/"
> )
> ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT
>
> The HTML source file contains:
>
> Image URL:  src="../media/logo.png"
> CSS URL : href="../css/twoColFixLtHdr.css"

You're not using staticfiles, because they will always result in
absolute path references. Try starting with the documentation and let us
know what you don't understand about it:
https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/

--
Melvyn Sopacua



On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
On 22-6-2012 15:53, surya wrote:
> This is my project folder hierarchy:
>
> project \
>            project \
>                       __init__.py
>                       settings.py
>                       urls.py
>                       views.py
>                       ... etc
>            templates \
>                            css \
>                                 index_css.css
>
>                            media \
>                                  logo.png
>
>                            templates \
>                                      home.html
>            manage.py
>
>
> So, these are the settings I made in "settings.py"
>
> currDir = os.path.dirname(__file__)
> templateDir_media =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "media")
> templateDir_css =
> os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css")
>
> STATICFILES_DIRS = (
>                     templateDir_media,
>                     templateDir_css,
>                     "d:/code/projects-dev/readdme/"
> )
> ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT
>
> The HTML source file contains:
>
> Image URL:  src="../media/logo.png"
> CSS URL : href="../css/twoColFixLtHdr.css"

You're not using staticfiles, because they will always result in
absolute path references. Try starting with the documentation and let us
know what you don't understand about it:
https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/

--
Melvyn Sopacua


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/v-7ndiut84gJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment