I am running GoogleAppEngine (GAE) 1.6.3 with Python 2.7 and Django 1.3 by having:
libraries:
- name: django
version: "1.3"
in my app.yaml
. The following should serve the admin media files at url /static/admin
:
- url: /static/admin
static_dir: django/contrib/admin/media
expiration: '0'
But I get 404s for such admin media (css, etc). Am I using the correct location for the Django admin's media file?
Following seems to work fine for me.
app.yaml
settings
Run
python manage.py collectstatic
. Now under your staticfiles admin folder should be created.is possible static file referenced by variable $PYTHON_LIB on deploy ??
file app.yaml
log local:
INFO 2012-04-03 02:06:19,200 dev_appserver.py:2884] "GET /admin/media/css/base.css HTTP/1.1" 200 -
INFO 2012-04-03 02:06:19,207 dev_appserver.py:2884] "GET /admin/media/css/dashboard.css HTTP/1.1" 200 -
INFO 2012-04-03 02:06:19,242 dev_appserver.py:2884] "GET /admin/media/img/admin/default-bg.gif HTTP/1.1" 200 -
log error deploy app:
2012-04-02 19:17:32.775 /admin/media/css/dashboard.css 404 6ms 0kb
Static file referenced by handler not found:$PYTHON_LIB/lib/django_1_3/django/contrib/admin/media/css/dashboard.css
The best way to do this is to copy or symlink the
media
directory into your app directory in your local files, so it is uploaded with your app's files. Then yourapp.yaml
can refer to the relative path in the app directory.There is a
$PYTHON_LIB
variable substitution you can use inapp.yaml
paths, but it looks like Django is not under$PYTHON_LIB
in the live version of the Python 2.7 runtime.I tried Philipp Keller's
collectstatic
, but I don't have that command available.So, add this handler to
app.yaml
:then, in
settings.py
, deleteADMIN_MEDIA_PREFIX
(removed in django 1.4) and add:and you have working css.
When adding this to
app.yaml
I was able to serve the CSS files by:
Adding this to
settings.py
:And then running
The admin media files appear correctly locally as well as on appspot.com. The last command copies the media files into the the
static/
directory. So in fact does what Dan Sanderson suggested but in a more automated way.