Thanks, Mike, for your reply.

This turned to be a very common problem...

Following your suggestion, I checked the page source (I am running
Safari browser on OSX 10.8) and indeed saw the references to the CSS
stylesheets:

<title>Site administration | Django site admin</title>
<link rel="stylesheet" type="text/css" href="/static/admin/css/
base.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/
dashboard.css" />

That, as well as your explanation, helped me realize that it was
looking for some STATIC directory, specified by variables such as
STATIC_ROOT or STATICFILES_DIR.

As I am running the built-in Django webserver, using,

       python manage.py runserver

I had expected it to be able to find its own stylesheets, and was
perplexed as to why it was unable to. I checked with the Django
documentation once again, at

    https://docs.djangoproject.com/en/dev/howto/static-files/

and noticed that it states:

   Configuring static files

   1. Make sure that django.contrib.staticfiles is included in your
INSTALLED_APPS.

That was it. I uncommented 'django.contrib.staticfiles', and lo and
behold, the admin pages are now styled properly because the
application can now find the STATIC directory containing the required
CSS files.

The Djangobook.com chapter does not mention this step in its
description of how to activate the admin interface

---------------------------------------------------------------
Activating the Admin Interface

The Django admin site is entirely optional, because only certain types
of sites need this functionality. That means you’ll need to take a few
steps to activate it in your project.

First, make a few changes to your settings file:

Add 'django.contrib.admin' to the INSTALLED_APPS setting. (The order
of INSTALLED_APPS doesn’t matter, but we like to keep things
alphabetical so it’s easy for a human to read.)
Make sure INSTALLED_APPS contains 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.messages' and
'django.contrib.sessions'. The Django admin site requires these three
packages. (If you’re following along with our ongoing mysite project,
note that we commented out these four INSTALLED_APPS entries in
Chapter 5. Uncomment them now.)
----------------------------------------------------------------

so perhaps that portion of the book should be updated to make certain
that django.contrib.staticfiles' also gets uncommented.

Many thanks for your helpful comments. They led me to finding out how
STATIC files were organized in Django.



On May 20, 10:02 pm, Mike Dewhirst <mi...@dewhirst.com.au> wrote:
> On 21/05/2013 11:07am, djingo django wrote:
>
>
>
> > I'm starting to learn Django and have been reading through the
> > djangobook.com. I am able to get the code running when  I come to
> > Chapter 6: The Django Admin Site, but it looks nothing like the
> > well-formed and well-styled screenshots in the documentation. The text
> > appears ragged and unstyled.
>
> > Am I missing a CSS stylesheet to make the admin interface line up and
> > get styled properly? How can I fix this?
>
> Yes. If you "View page source" in your browser you should see something
> like this ...
>
> <link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" />
> <link rel="stylesheet" type="text/css"
> href="/static/admin/css/dashboard.css" />
>
> So if the stylesheets cannot be found, which web server are you using?
>
> If you are not using the Django dev server, you need to configure your
> web server to look for such static files in a particular location
> (defined in settings.py as STATIC_ROOT) then run "manage.py
> collectstatic" to put them there.
>
> https://docs.djangoproject.com/en/1.5/howto/static-files/
>
>
>
>
>
>
>
>
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group athttp://groups.google.com/group/django-users?hl=en.
> > For more options, visithttps://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to