static files

38 views
Skip to first unread message

luca72

unread,
Oct 11, 2012, 10:49:05 AM10/11/12
to django...@googlegroups.com
hello my project is lacated here:

/home/
  /luca72
    /Scrivania
      /Quintas_Disegno_definitivo
        /quintas/ here i have the file manage.py ,

than i have the file settings,py here:
/home
   /luca72
      /Scrivania
         /Quintas_Disegno_definitivo
            /quintas
               /quintas, here i have add a folder "static" with and image called PAE.jpg.

How i have to configure the file setting.py in a way that in my template when i write via CSS background-image : url("PAE.jpg") the image is load

I have try a lot of thing but i get that the image is not found.

I use apache in localhost.

Thaks

Luca

Brad Pitcher

unread,
Oct 11, 2012, 11:06:33 AM10/11/12
to django...@googlegroups.com

I believe the best way of doing this is to have your image(s) in static/images and your css in static/css.  Then you can use a relative URL to set the background image like so:

background-image : url("../images/PAE.jpg")

It's better not to have any CSS mixed in with your HTML anyway.

--
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/-/VXS19g9Ie7MJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

luca72

unread,
Oct 12, 2012, 2:46:01 AM10/12/12
to django...@googlegroups.com
Thanks
 i have try but with no result, i have set as follow:

MEDIA_ROOT = '/home/luca72/Scrivania/Quintas_Disegno_definitivo/quintas/quintas/static/'
MEDIA_URL = '/static/'
STATIC_URL = ''
STATIC_ROOT = ''
STATICFILES_DIRS = ('/home/luca72/Scrivania/Quintas_Disegno_definitivo/quintas/quintas/static/',
inside the static i have made two folders images and css, now in the template i load the css in this way  <link rel="stylesheet" type="text/css" href="..css/base.css" />

But i get that he is not find, but the file base.css is inside the folder.

i think  that i have to configure MEDIA_ and STATIC_ ROOT and URL correctly.

Can you help me to configure it.

Thanks

Luca 

acellam guy

unread,
Oct 12, 2012, 5:39:48 AM10/12/12
to django...@googlegroups.com
Make sure that all your static settings are okay on your app. Since you mentioned that you are using apache;
install mod_wsgi

 be sure to add some stuff to your httpd.conf file eg;
#added by guy
LoadModule wsgi_module modules/mod_wsgi.so

<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
</IfModule>

Alias /appname/robots.txt "absolutepathtoapp/robots.txt"
Alias /appname/favicon.ico "absolutepathtoapp/favicon.ico"

#match main site resources
AliasMatch ^/appname/staticfolder/(.*) absolutepathtoapp/staticfolder/$1

Alias /appname/staticmediafolder/ "absolutepathtoapp/staticmediafolder/"

WSGIScriptAlias /appname"absolutepathtoapp/wsgi.py"

<Directory "absolutepathtoapprootfolder/Stark">
    AllowOverride None
    Options None
    Order deny,allow
    Allow from all
</Directory>
#end of added by guy

Replace the words applicably


To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/FqgYBYewPcUJ.
Reply all
Reply to author
Forward
0 new messages