Django and CSS

2009-06-18 Thread Chris DPS

Hi,

I'm new to Django.
I've read the doc: 
http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs
which is about static files but still do not quite understand what to
call everything and it isn't working
On my development machine, I want to use this hack and not deal with
other servers.
Please help.


here is my file structure:

/mysite/  - has all the .py files
/mysite/templates/  - has all the html templates
/mysite/templates/path_media/ - has the CSS document and pictures


Now, how should I modify this:

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/path/to/media'})

'/path/to/media' should be changed to what?


And is this what I want for my style href? :

http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django and CSS

2008-04-23 Thread Rodney Topor

Is there something strange about using CSS with Django?  When I make
my templates refer to external CSS files, the appearance of the
template changes, but not the way the CSS file says it should?  Is
there something special I need to know about this?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2008-08-27 Thread jgomo3

I have no problem serving static content, but i'm still confused about
the MEDIA_ROOT and MEDIA_URL.

Why the ROOT if i have the URL?
how do you actually use those variables?

In production and in develpment server i havent used them, i simply
serve the statics content in some virtual server for that (avoiding
the use of django.views.static.serve becuase it force many changes
when passing thr project from the develpment server to apache).

Are they used to avoid hard code the URL when referencing to things
like css? (example, to avoid 'href="http://example.com/css/site.css";'
and use 'href="http://%s/css/site.css' % MEDIA_URL).
If that then:
  Why the MEDIA_ROOT?
  For accessing the media files vie the filesystem on views or
someting?
  If that then:
It is confusing the comment on the setting file in the variable
MEDIA_URL wich says "This URL handles the media served from
MEDIA_ROOT" because the media files accessed via the MEDIA_URL doesn't
have to be in the same machine. So, is intended that the two variables
refer to the same files?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2008-08-27 Thread Juan Miguel
MEDIA_URL: Says what is the RELATIVE PATH to media files. So it is relative
to the root dir in server. Used when referring links in templates. I.E:
http://{{MEDIA_URL}}img/img.jpg. It has many other uses but the most
important is the one before.

MEDIA_ROOT: Says what is the ABSOLUTE PATH to media files. So, it is
relative to a LOCAL dir (in server or not). Used to say the exact dir (not
relative to any server) where media is.

I hope u to understand the difference better.

Up Django!

2008/8/27 jgomo3 <[EMAIL PROTECTED]>

>
> I have no problem serving static content, but i'm still confused about
> the MEDIA_ROOT and MEDIA_URL.
>
> Why the ROOT if i have the URL?
> how do you actually use those variables?
>
> In production and in develpment server i havent used them, i simply
> serve the statics content in some virtual server for that (avoiding
> the use of django.views.static.serve becuase it force many changes
> when passing thr project from the develpment server to apache).
>
> Are they used to avoid hard code the URL when referencing to things
> like css? (example, to avoid 'href="http://example.com/css/site.css";'
> and use 'href="http://%s/css/site.css' % MEDIA_URL).
> If that then:
>  Why the MEDIA_ROOT?
>  For accessing the media files vie the filesystem on views or
> someting?
>  If that then:
>It is confusing the comment on the setting file in the variable
> MEDIA_URL wich says "This URL handles the media served from
> MEDIA_ROOT" because the media files accessed via the MEDIA_URL doesn't
> have to be in the same machine. So, is intended that the two variables
> refer to the same files?
> >
>


-- 
---
Juan M.A.N.
---

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2008-08-28 Thread varikin

MEDIA_ROOT is the local path to the files on the server.  One place
this is used is with uploading files.  So uploaded files will be
placed in MEDIA_ROOT/some-upload-dir.  I don't know about other uses,
though.

John
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2008-08-29 Thread jgomo3

Juan Miguel: Confirm my suspects, thankyou.
varikin: how i didn't think on it before, thanyou.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2009-06-18 Thread Brian Neal

On Jun 18, 2:50 pm, Chris DPS  wrote:
> Hi,
>
> I'm new to Django.
> I've read the 
> doc:http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs
> which is about static files but still do not quite understand what to
> call everything and it isn't working
> On my development machine, I want to use this hack and not deal with
> other servers.
> Please help.
>
> here is my file structure:
>
> /mysite/  - has all the .py files
> /mysite/templates/  - has all the html templates
> /mysite/templates/path_media/ - has the CSS document and pictures
>
> Now, how should I modify this:
>
> (r'^site_media/(?P.*)$', 'django.views.static.serve',
>         {'document_root': '/path/to/media'})
>
> '/path/to/media' should be changed to what?

Mine looks like this:

from django.conf import settings
...
if settings.DEBUG:
   urlpatterns += patterns('',
  (r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
   )

>
> And is this what I want for my style href? :
>
> 

http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media

>
> What about when I pull an image using the css document:
>
> url("site_media/foo.jpg")

Paths inside CSS files are relative to the CSS files themselves. I
typically use relative paths inside CSS files, e.g.

url("../images/foo.jpg")

Best,
BN

--~--~-~--~~~---~--~~
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: Django and CSS

2008-04-23 Thread Darryl Ross

Rodney Topor wrote:

Is there something strange about using CSS with Django?  When I make
my templates refer to external CSS files, the appearance of the
template changes, but not the way the CSS file says it should?  Is
there something special I need to know about this?


Nothing that I am aware of. It might help if you are able to paste a 
short snippet of the HTML and relevant CSS is that not appearing how you 
think it should.


Regards
-Darryl



signature.asc
Description: OpenPGP digital signature


Re: Django and CSS

2008-04-24 Thread Rodney Topor

OK, sorry for the unclear message.

I've now discovered that if I use an embedded CSS file in a template -
h1 { color: red} - then it works correctly.
But if I use an external CSS file in a template -  - then, even if the
style sheet only changes font colors, the effect is that the font
style is changed, the font size is changed, and the background
changes.  Now, perhaps the style sheet is not being found.

So, if my project has a directory structure "mysite/templates/app/
template.html", then in which directory should I place the CSS file?

This prompts me to ask a related question: If the mysite project has
two apps, is it better to have a separate templates directory within
each app, or a single template directory within the project with a
subdirectory for each app as suggested above, or a single template
directory containing all templates.  (The last solution seems wrong,
poorly structured.)

Rodney

On Apr 24, 12:51 pm, Darryl Ross <[EMAIL PROTECTED]> wrote:
> Rodney Topor wrote:
> > Is there something strange about using CSS with Django?  When I make
> > my templates refer to external CSS files, the appearance of the
> > template changes, but not the way the CSS file says it should?  Is
> > there something special I need to know about this?
>
> Nothing that I am aware of. It might help if you are able to paste a
> short snippet of the HTML and relevant CSS is that not appearing how you
> think it should.
>
> Regards
> -Darryl
>
>  signature.asc
> 1KDownload
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2008-04-24 Thread gmacgregor


On Apr 24, 10:49 pm, Rodney Topor <[EMAIL PROTECTED]> wrote:
> So, if my project has a directory structure "mysite/templates/app/
> template.html", then in which directory should I place the CSS file?

You'll find this thread helpful:

http://groups.google.com/group/django-users/browse_thread/thread/906a11a1c86e13b0

> This prompts me to ask a related question: If the mysite project has
> two apps, is it better to have a separate templates directory within
> each app, or a single template directory within the project with a
> subdirectory for each app as suggested above, or a single template
> directory containing all templates.  (The last solution seems wrong,
> poorly structured.)

It's best to create a "templates" directory and then within that
directory create directories that correspond to each of your
application names:

project
|
templates
|
 blog
 template.html
 template.html
 photos
 template.html


Just make sure to set TEMPLATE_DIRS properly in your project's
settings file.

Greg
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2008-04-24 Thread Erik Vorhes

Put your CSS files in your media directory. If your media url is
"http://yoursite/media/";, then you could do something like  and you should see your intended
style.



On Thu, Apr 24, 2008 at 10:01 PM, gmacgregor <[EMAIL PROTECTED]> wrote:
>
>
>  On Apr 24, 10:49 pm, Rodney Topor <[EMAIL PROTECTED]> wrote:
>  > So, if my project has a directory structure "mysite/templates/app/
>  > template.html", then in which directory should I place the CSS file?
>
>  You'll find this thread helpful:
>
>  
> http://groups.google.com/group/django-users/browse_thread/thread/906a11a1c86e13b0
>
>
>  > This prompts me to ask a related question: If the mysite project has
>  > two apps, is it better to have a separate templates directory within
>  > each app, or a single template directory within the project with a
>  > subdirectory for each app as suggested above, or a single template
>  > directory containing all templates.  (The last solution seems wrong,
>  > poorly structured.)
>
>  It's best to create a "templates" directory and then within that
>  directory create directories that correspond to each of your
>  application names:
>
>  project
> |
> templates
> |
>  blog
>  template.html
>  template.html
>  photos
>  template.html
>
>
>  Just make sure to set TEMPLATE_DIRS properly in your project's
>  settings file.
>
>  Greg
>
>
> >
>



-- 
portfolio: http://textivism.com/
blog: http://erikanderica.org/erik/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2008-04-24 Thread Rodney Topor



On Apr 25, 1:01 pm, gmacgregor <[EMAIL PROTECTED]> wrote:
>
> http://groups.google.com/group/django-users/browse_thread/thread/906a...

Thank you.  Now I understand this issue.

> It's best to create a "templates" directory and then within that
> directory create directories that correspond to each of your
> application names:

OK, thank you.  But doesn't this make each application less self-
contained, and hence harder to reuse?

Rodney
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and CSS

2008-04-24 Thread Darryl Ross

Rodney Topor wrote:

OK, sorry for the unclear message.

I've now discovered that if I use an embedded CSS file in a template -
h1 { color: red} - then it works correctly.
But if I use an external CSS file in a template -  - then, even if the
style sheet only changes font colors, the effect is that the font
style is changed, the font size is changed, and the background
changes.  Now, perhaps the style sheet is not being found.


Assuming you mean 'unchanged', then it's quite likely. Especially if you 
haven't configured your web server to bypass django for loading the CSS 
files.



So, if my project has a directory structure "mysite/templates/app/
template.html", then in which directory should I place the CSS file?


The physical directory the template comes from has absolutely no bearing 
on the URL structure as far as the web server is concerned. What is 
important for external media files (which includes the CSS, any 
javascript files and the image files) is whether the web server knows 
how to find the files.


I put all my media files into a directory structure under the project 
directory called 'webroot'. And then use an 'Alias' option in Apache to 
point http://example.com/site-media/ to the webroot folder. You also 
need to tell it not to use mod_python or whatever mechanism you're using 
for django. In the template files I then reference the CSS like:


  

If you are using the generic views, or are passing an instance of 
RequestContext into the render_to_response function, and have MEDIA_URL 
set correctly in your settings.py file, then you can simplify this as:


  


This prompts me to ask a related question: If the mysite project has
two apps, is it better to have a separate templates directory within
each app, or a single template directory within the project with a
subdirectory for each app as suggested above, or a single template
directory containing all templates.  (The last solution seems wrong,
poorly structured.)


I do it both ways. If I think the app might be useful elsewhere or is 
pretty much self-container, then I will put them into the application 
directory. If they are specific to the website, or someone else is 
maintaining the HTML (I'm a programmer, not a artist!) then I'll put 
them in a top level templates folder.


Regards
Darryl

--

Darryl Ross
Director
AFOYI, "Information Technology Solutions"
p +61 8 7127 1831
f +61 8 8425 9607
e [EMAIL PROTECTED]




signature.asc
Description: OpenPGP digital signature