Closed GoogleCodeExporter closed 9 years ago
a bit strange. from what I see here this should work.
however, did you try using --adminmedia ...
python manage.py runserver localhost:8000
--adminmedia=/Users/Nick/Code/pmw/media/grappelli/
another thing you could try is to explicitely define your admin-media directory
as
static.server like this:
(r'^media/grappelli/(?P<path>.*)$', 'django.views.static.serve',
{'document_root':
'/Users/Nick/Code/pmw/media/grappelli/'}),
hope this helps.
regards,
patrick
Original comment by sehmaschine
on 22 Dec 2009 at 10:11
Ah - good tips - I knew there had to be some server-level switch the debug
server is
making for admin media, as it always defaults to the django install's
admin-media.
I'll give those a try.
Thanks!
Original comment by intellin...@gmail.com
on 22 Dec 2009 at 1:30
By the way, I did try the second thing - explicitly defining the admin-media
dir with
the static server with no luck.
Original comment by intellin...@gmail.com
on 22 Dec 2009 at 1:31
For me, using adminmedia option is kind of workaround - it works but there
should
be a better solution.
It would be much simpler to put additional media at, for example, 'grappelli'
directory
within static document_root. Templates are already overridden so implementation
would be quite easy ( src={{ MEDIA_URL}}grappelli/... ), as far as I can
imagine as I
don't really know the impact on the admin internals.
And usage of 'adminmedia' optition should probably be pointed out at install
documentation (I haven't been even aware of it's existence ;-)).
Oh, and patrick, second approach you have suggested doesn't really work, at
least for
me - I'm using Django 1.1. I'm trying to get it working this way for much too
long
and it is very frustrating...
Have this at my settings module:
ADMIN_MEDIA_PREFIX = '/admin-media/'
And this at urls.py:
if settings.DEBUG:
urlpatterns += patterns('django.views',
# admin-media
(r'^%s(?P<path>.*)$' % settings.ADMIN_MEDIA_PREFIX[1:] , 'static.serve',
{
'document_root': os.path.join(settings.PROJECT_ROOT, 'admin-media'),
'show_indexes' : True,
}),
...
and its before I bind admin app.
It seems that changes at urls.py didn't go into life as I got strange error if
I try to list
the directory: "Permission denied: /admin-media/"...
I tried to directly run django.views.static.directory_index on my
django/contrib/admin/media directory and it returned as expected (means without
any error). So I'm totally lost here.
Original comment by LukaszBa...@gmail.com
on 22 Dec 2009 at 1:35
I had this problem for a while and finally got a good understanding of what's
going on.
You need to use the --adminmedia flag because otherwise django will default the
admin
folder to django/contrib/admin/media in your pythonpath. *And it will also set
up the
static serve urlconf entries automatically. This is the real problem. You
can't
just override the urlconf settings because the admin will still have the file
system
path set wrong. So you need to set the --adminmedia path as well so the urlconf
looks in the right place.
The only thing I would recommend is to make the setup instructions a little more
clear. The grappelli media folder _completely replaces_ the default django
media
folder. So just change everything to point there and you're in good shape.
Original comment by marco.ro...@gmail.com
on 7 Jan 2010 at 3:27
Ah - awesome. Thank you for the explanation. That pretty much drove me crazy
for 8+
hours.
Original comment by intellin...@gmail.com
on 7 Jan 2010 at 3:54
usage of --adminmedia is in the docs now ... thanks for the hint.
but: you can put grappelli-media wherever you want to ... you just need to tell
your
server to use that directory as your (admin)-media-directory. of course,
that´s not
necessary if you use djangos built-in dev-server. without the dev-server, you
need to
change your server-setup (e.g., if you use /admin-media/ as your
ADMIN_MEDIA_PREFIX,
you need to tell your server how /admin-media/ is served).
Original comment by sehmaschine
on 7 Jan 2010 at 4:19
See this answer from stackoverflow:
http://stackoverflow.com/questions/1081596/django-serving-admin-
media-files#1656828
It seems that the ADMIN_MEDIA_PREFIX only has effect if the full domain name is
supplied:
ADMIN_MEDIA_PREFIX = 'http:/localhost:8000/admin-media/'
Original comment by dirk.van...@gmail.com
on 7 Apr 2010 at 1:05
@dirk: we never use the full domain with ADMIN_MEDIA_PREFIX, so that can´t be
an issue.
Original comment by sehmaschine
on 8 Apr 2010 at 10:32
@dirk: thanks! that helped!
Original comment by martin.b...@gmail.com
on 2 Sep 2010 at 9:50
Original issue reported on code.google.com by
intellin...@gmail.com
on 21 Dec 2009 at 9:11