Jump to content

Django Admin CSS files not found


Recommended Posts

Hi, as a new developer I have been having problems deploying my django/python application to johnny.  After several attempts, I now have the Hello World screen working, and I have access to /admin as well.  However I cannot seem to be able to get the admin functions to access their CSS and other static files.

site is http://www.hannaford.id.au/admin/

and output is 

Site administration
Recent actions My actions

So clearly I am logged in, but my attempts to follow advice in the forums, and elsewhere has not worked.

Here is the tail end of my settings.py file..

# Static files (CSS, JavaScript, Images)

STATIC_URL = 'hello/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'hello/static/')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "hello/static/"),
    '/home/paulfhan/public_html/hello/static/',
    'c:/Users/Paul/Desktop/Projects/hello/hello/static/',
]

and here is my dispatch.wsg file

import os, sys
 
# edit your username below
sys.path.append("/home/paulfhan/public_html")
 
from django.core.wsgi import get_wsgi_application
 
os.environ['DJANGO_SETTINGS_MODULE'] = 'hello.settings'
 
application = get_wsgi_application()
 

and my .htaccess file

RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(hello/dispatch\.wsgi/.*)$ - [L]
RewriteRule ^(.*)$ hello/dispatch.wsgi/$1 [QSA,PT,L]
RewriteRule ^(hello/static/.*)$ - [L]

.  the directory tree is

hello
│   └───hello
│       ├───static
│       │   └───hello
│       │       ├───admin
│       │       │   ├───css
│       │       │   │   └───vendor
│       │       │   │       └───select2
│       │       │   ├───fonts
│       │       │   ├───img
│       │       │   │   └───gis
│       │       │   └───js
│       │       │       ├───admin
│       │       │       └───vendor
│       │       │           ├───jquery
│       │       │           ├───select2
│       │       │           │   └───i18n
│       │       │           └───xregexp
│       │       ├───css
│       │       └───images
│       └───__pycache__

 

I would be grateful for help with this.

 

Link to comment
Share on other sites

You need to make an exception in the .htaccess so your .css files are not handled by dispatch.wsgi. You can do this by duplicating the media line and changing the directory to static. You could also host your .css files in the media directory since they already have an exception in .htaccess.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...