Вопрос

I browsed these question but not found correct answer. Here is my problem..

I have some static files.Here is the dir..

/home/user/djangoproject/djangoapp/static

/home/user/djangoproject/templates/base.html (where I have modify some for django admin page)

After setting debug = False, I have change setting.py like this

DEBUG = False
ALLOWED_HOSTS = ['*',]
STATIC_URL = '/static/'
STATIC_ROOT = "/home/user/djangoproject/djangoapp/static/"

and my urls.py is

urlpatterns = patterns('',
                 url(r'^admin/', include(admin.site.urls)),
                 url(r'^$',login),# and some more views
    )+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

After that I have collect all admin static to my app's custom static dir path like this..

/home/user/djangoproject/djangoapp/static/admin/css & all others

Now my problem is that when I am using my custom static file, It's working but for example admin login page & admin site, admin static file is not working..So where am I doing wrong, or what extra I have to do.

Thanks in advance...

Это было полезно?

Решение

You need to set up a web server to serve the static files. If you are using Apache, adding something along the lines of

Alias /static/ /home/user/djangoproject/djangoapp/static/
<Directory /home/user/djangoproject/djangoapp/static>
        Order deny,allow
        Allow from all
</Directory>

to httpd.conf should do the trick. For more info see https://docs.djangoproject.com/en/1.6/howto/static-files/deployment/

To serve also the Django project through Apache, add

WSGIScriptAlias / /home/user/djangoproject/djangoproject/wsgi.py
WSGIPythonPath /home/user/djangoproject

<Directory /home/user/djangoproject/djangoproject>
  <Files wsgi.py>
    Order deny,allow
    Allow from all
  </Files>
</Directory>

Alias /static/ /home/user/djangoproject/djangoapp/static/
<Directory /home/user/djangoproject/djangoapp/static>
  Order deny,allow
  Allow from all
</Directory>

to httpd.conf. For instructions about how to set up Django with Apache, see https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top