On 24 August 2011 09:40, Reinout van Rees <rein...@vanrees.org> wrote:
> On 23-08-11 13:25, Caomhin wrote:
>>
>> I confess, I'm lost!  I've just tried starting my first new site since
>> upgrading to Django 1.3 and the new staticfiles settings seem to be
>> taunting me.  I've tried a number of variations but every setting I
>> have returns a 404 for the admin interface css.  Here's what I have
>> just now:
>>
>> MEDIA_URL = 'media/'
>
> I'd put a slash in front of that, but that shouldn't be related to your
> admin css problem.

Well spotted, cheers

>> %python manage.py findstatic admin/css/dashboard.css
>> Found 'admin/css/dashboard.css' here:
>>   /usr/local/lib/python2.7/site-packages/django/contrib/admin/media/
>> css/dashboard.css
>
> Yep, it finds it through the "django app"'s static/ directory.

Aah okay, this is definitely something I had missed.  With hindsight I
should have tried findstatic before I started adding to the search
paths and then I might have figured out that there was a default
static folder that gets checked.  There's a chance I was over
confident about that one :-)  It makes sense though.

>> So I'm fairly happy that django is finding these files in a sane an
>> happy manner, and the failure on the final one gives me a sense of
>> reassurance that the paths are all making sense, but still the
>> templates are generating<link rel="stylesheet" type="text/css" href="/
>> static/admin/css/dashboard.css" />  and the stylesheets are not found.
>
> When are they not found? Both in development and on the server? Or only on
> the server?

Well as it's a totally new project I'm happily doing the early stages
of development on the server itself, my set-up means it's barely more
effort than using the development server at this stage of the process
and it saves the hassle of moving it to the server afterwards.  A lazy
shortcut in other words.

> On the server, you need to tell apache (or whatever you're using) to look in
> the right directory given your STATIC_URL:
>
>  # django-staticfiles: STATIC_URL = '/static_media/'
>  Alias /static_media/ /path/to/your/collected/static/files/

Okay, I did a bit more fiddling last night and you just confirmed that
what I thought had been a workaround was actually the real solution,
namely that I still need to "collect" the default files for a live
server.

Perhaps it's me but that steps feels unintuitive in the docs to me -
the comparison with templates meant I felt I would be just serving up
the files in /usr/local/lib/python2.7/site-packages/django/contrib/admin/media/
directly, after all I don't copy the templates over unless I want to
override them (and yes, I realise that means I really should have
spotted django had a default static directory).

Basically static files is just an easier way to copy the admin
css/js/etc. to the project specific directories rather than serving
them directly from the master location?  collectstatic -l in the
development version is probably the closest to what I assumed would
happen.

I feel a lot clearer now, thank you.

Kevin

-- 
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.

Reply via email to