0

Django 1.4 release notes state:

If you're implicitly relying on the path of the admin static files within Django's source code, you'll need to update that path. The files were moved from django/contrib/admin/media/ to django/contrib/admin/static/admin/.

Could somebody explain how this is done exactly? Up to Django 1.3 we used ADMIN_MEDIA_PREFIX in settings.py, which is now deprecated. However, since we are developing all the time on our static files (js, css, ...), the staticfiles app is a rather annoying nogo for us. Calling collectstatic after each modification is a nightmare :-P

A pure Python/Django solution would be great. If that's impossible, we are using LighTPD as server and not Apache.

Simon Steinberger
  • 6,605
  • 5
  • 55
  • 97

2 Answers2

1

manage.py collectstatic is used when you deploy, during development you can have django serve your static and media files by adding this to your url.py:

from django.conf.urls.static import static
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

...
...

if settings.DEBUG:
   # add one of these for every non-static root you want to serve
   urlpatterns+= static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
   # this take cares of static media (i.e. bundled in apps, and specified in settings)
   urlpatterns+= staticfiles_urlpatterns()

This will also serve all the static files that are bundled with reusable apps. This avoids the real nightmare of having to add symlinks to your webserver root for every third party app per project!

ashwoods
  • 2,209
  • 1
  • 22
  • 36
  • Thanks - I really appreciate your answer and voted for it. However, *cough* we are far too often developing *directly* on our life server - inside the statics! We have such dynamic projects, which need updating, caring, fixing, etc. on a daily basis. – Simon Steinberger Apr 02 '12 at 14:26
  • even if you are hotfixing, you should go through version control and a deploy script. We have our CI server checkout the project when it registers changes, and runs the fabric update scripts when needed. That includes database changes, changes to the system, everything. can't get more daily than that. – ashwoods Apr 02 '12 at 14:36
0

Oops, I just found the solution in Django's new documentation:

https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/#serving-the-admin-files

Simon Steinberger
  • 6,605
  • 5
  • 55
  • 97