django admin styling lost

I deleted and installed an app using the manual setup for django. I edited the static file location both in and in the web tab to find my files and it works fine. The admin had styling, but now doesn't -- it seems to be looking in the PA static location for the files. How do I fix it so the admin looks where my static files are?

You have two choices

1) the slightly hacky choice is to create an extra static files entry that points at the system-installed admin media folder:

/static/admin/ --> /usr/local/lib/python3.3/dist-packages/django/contrib/admin/static/admin

2) the way you're really supposed to do it is to use the Django collectstatic command:

python3 collectstatic

Which will gather up all the static files from all your INSTALLED_APPS (including the admin app) and put them into the static folder you defined as STATIC_ROOT in your Have a look in the Django docs for more info.

Thanks. I'll give it a shot!

No, I ran collectstatic and it didn't work

Got much output like this

Copying '/usr/local/lib/python3.3/dist-packages/django/contrib/admin/static/admin/img/tooltag-add.gif'
Copying '/usr/local/lib/python3.3/dist-packages/django/contrib/admin/static/admin/img/gis/move_vertex_on.png'
Copying '/usr/local/lib/python3.3/dist-packages/django/contrib/admin/static/admin/img/gis/move_vertex_off.png'

But it doesn't seem to find the css

<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" />
<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="/static/admin/css/ie.css" /><![endif]-->   
<script type="text/javascript">window.__admin_media_prefix__ = "/static/admin/";</script>

Any clue? — My app static files seem to work fine.

UPDATE: Ah, collectstatic had copied the files to the root level of my app, not into the static folder (does one need to be in the static folder when one runs collectstatic?)

Moved it by hand, and it works fine.

By the way, just out of curiosity, how does one actually DO

/static/admin/ --> /usr/local/lib/python3.3/dist-packages/django/contrib/admin/static/admin

That is, how does that translate into actual code?

It's not translated to code, it's a description of the entries you put into the static files section on your web app configuration page.

Adding /static/admin/ to a URL field fixes the problem

Harry's comment fixed the problem(the 1st choice) but there's no need to run collectstatic because most likely django.contrib.admin is already in your by django 1.9 and above.

The real problem is that the django admin templates deep in the sitepackages folder cannot reach the css files thru its url because it is not yet existing here in pythonanywhere.

That's why you need to add:

  1. another URL in the Static files: located inside the Web beside Console, Files, and Databases
  2. put /static/admin/ in the value of URL and for the path, it depends on where your django admin static files are located. The common path is this one (if you're using a virtual envrionment) /home/<username>/.virtualenvs/<virtrualenvname>/lib/python3.6/site-packages/django/contrib/admin/static/admin
  3. If you aren't using a virtual environment /usr/local/lib/python3.3/dist-packages/django/contrib/admin/static/admin as what harry placed here in the first reply comment is the path.

I've uploaded a picture to better understand the how to. Hope it helps! No coding was necessary.

Here is the image for the solution

That will definitely work, and it was our recommended solution for some time. But because collectstatic copies all of the stuff from inside the virtualenv into your project's static files dir, it means that you get one fewer line of config in the static files table, which keeps things just that little bit simpler -- so we recommend that nowadays, just to reduce confusion.