Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 20, 2011 00:45:52

Eric C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django + CSS


Unless you are trying to serve your CSS inline, which it doesn't appear to be
the case from your post, why wouldn't you serve your CSS files like any other
static file? Serve the static file with your web server or CDN and put the url
in the template, no magic required.

On Jan 19, 2011, at 3:58 PM, brian.mus...@ff0000.com wrote:

> Is it me or does it blow your mind that there is not one standard way
> of importing something as common as CSS files into Django templates?
> I realize there are a plethora of options as mentioned on the official
> site here:http://docs.djangoproject.com/en/dev/howto/static-files/> None of which actually ended up working for me and instead ended up
> using this:
>
> urlpatterns in urls.py:
> (r'^static/(?P<path>.*)$', 'django.views.static.serve',
> {'document_root': '/Users/home/djcode/mysite/media/
> css/','show_indexes' : True}),
>
> and then on my actual template page:
> <link rel="stylesheet" type="text/css" href="static/my.css" />
>
> I suppose I was feeling a little misdirected by the default
> settings.py in my projects folder where CSS and other Media are
> supposed to be stored.
> ADMIN_MEDIA_PREFIX = 'media/' That was not used at all in the
> solution I ended up using which does work.
>
> My main complaint is this - for something so common as importing CSS
> into django templates - why not just make it painfully obvious in the
> documentation/djangobook with one golden way of doing so - why does
> everything have to be so modular, etc? It starts to feel
> counterproductive at a certain point - like why I am not just writing
> this in python myself if there are going to be so many options. I
> think django could use a little tightening up. I understand it's loose
> coupling ways, etc - but don't use that as a shield for something
> possibly unfinished? The solution I ended up using felt like a hack
> for something so common. My two cents.
>
> --
> 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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 20, 2011 00:49:26

O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django + CSS


Same problem here. Follow those rules, is simple and is working
perfect.http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-files-css.htmlOn Jan 20, 1:58 am, "brian.mus...@ff0000.com"
<brian.mus...@ff0000.com> wrote:
> Is it me or does it blow your mind that there is not one standard way
> of importing something as common as CSS files into Django templates?
> I realize there are a plethora of options as mentioned on the official
> site here:http://docs.djangoproject.com/en/dev/howto/static-files/> None of which actually ended up working for me and instead ended up
> using this:
>
> urlpatterns in urls.py:
> (r'^static/(?P<path>.*)$', 'django.views.static.serve',
> {'document_root': '/Users/home/djcode/mysite/media/
> css/','show_indexes' : True}),
>
> and then on my actual template page:
> <link rel="stylesheet" type="text/css" href="static/my.css" />
>
> I suppose I was feeling a little misdirected by the default
> settings.py in my projects folder where CSS and other Media are
> supposed to be stored.
> ADMIN_MEDIA_PREFIX = 'media/'  That was not used at all in the
> solution I ended up using which does work.
>
> My main complaint is this - for something so common as importing CSS
> into django templates - why not just make it painfully obvious in the
> documentation/djangobook with one golden way of doing so - why does
> everything have to be so modular, etc?  It starts to feel
> counterproductive at a certain point - like why I am not just writing
> this in python myself if there are going to be so many options.  I
> think django could use a little tightening up. I understand it's loose
> coupling ways, etc - but don't use that as a shield for something
> possibly unfinished? The solution I ended up using felt like a hack
> for something so common.  My two cents.

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 20, 2011 03:56:33

Vovk D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django + CSS


Man, this is just a quote from Django Documentation.

2011/1/20 Osiaq <osiaq.net...@gmail.com>

> Same problem here. Follow those rules, is simple and is working
> perfect.
>
>
>http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-files-css.html>
>


--
*Vovk Donets*
python/django developer

skype: suunbeeam
icq: 232490857
mail: donets.vladi...@gmail.com

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 21, 2011 19:11:35

b.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django + CSS


Osiaq thanks dude, it worked! Not sure why it had to be so
complicated. I just started with this stuff just recently (python +
django) - working my way thru the django book. When u search Django
CSS there are dozens of different explanations for how to import
(import css files) - there should really just be one way I think - why
does it have to be so modular and abstract?

@ Eric of course I tried putting full url in template first and u know
that didn't work - I wish it were that simple. That's what I'm
talking about. Why not?



On Jan 19, 7:56 pm, Vovk Donets <donets.vladi...@gmail.com> wrote:
> Man, this is just a quote from Django Documentation.
>
> 2011/1/20 Osiaq <osiaq.net...@gmail.com>
>
> > Same problem here. Follow those rules, is simple and is working
> > perfect.
>
> >http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-f...
>
> --
> *Vovk Donets*
>  python/django developer
>
> skype:  suunbeeam
> icq:      232490857
> mail:    donets.vladi...@gmail.com

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 Jan. 21, 2011 19:13:56

Javier G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django + CSS


On Fri, Jan 21, 2011 at 2:11 PM, brian.mus...@ff0000.com
<brian.mus...@ff0000.com> wrote:
> why
> does it have to be so modular and abstract?

because it's a good thing?

of course, there are several 'shortcuts' for common ways to tie
modules together. maybe there could be a couple more

--
Javier

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#6 Jan. 21, 2011 19:28:13

Mike R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django + CSS


On Friday, January 21, 2011 11:11:30 am brian.mus...@ff0000.com wrote:

> @ Eric of course I tried putting full url in template first and u know
> that didn't work - I wish it were that simple. That's what I'm
> talking about. Why not?
>

What do you mean?

<link rel="stylesheet" href="http://mysite.com/media/stylessheet.css";
type="text/css">

does work.

The real problem here is serving up the css file. Most peopole have a hard
time configuring the server to work nicely with django, but most people make
this harder than it needs to be. This is one reason I recommend developers
learn how to admin the servers they are working on, so it doesn't become a
problem.

FTR:
Using {{ MEDI_URL }} is a convience not to tie in the media server to one
location and you only need to update the settings.py file to change that site
wide instead of searching for every place you've hardccoded it in.


Mike

--
Reader, suppose you were an idiot. And suppose you were a member of
Congress. But I repeat myself.
-- Mark Twain

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#7 Jan. 22, 2011 01:57:04

O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django + CSS


No Vovk, it is not :) Official Django docs are missing some vital
stuff :)

On Jan 20, 5:56 am, Vovk Donets <donets.vladi...@gmail.com> wrote:
> Man, this is just a quote from Django Documentation.
>
> 2011/1/20 Osiaq <osiaq.net...@gmail.com>
>
> > Same problem here. Follow those rules, is simple and is working
> > perfect.
>
> >http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-f...
>
> --
> *Vovk Donets*
>  python/django developer
>
> skype:  suunbeeam
> icq:      232490857
> mail:    donets.vladi...@gmail.com

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 24th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support