django : Serving static files through nginx

后端 未结 5 1817
醉话见心
醉话见心 2020-12-04 09:40

I\'m using apache+mod_wsgi for django.
And all css/js/images are served through nginx.
For some odd reason, when others/friends/colleagues try accessing

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 10:29

    Fim & Alexander - Thanks for the hints those helped.
    Here is how I solved it for anyone stuck in the same boat -

    settings.py -

    >MEDIA_ROOT = ''    
    MEDIA_URL = 'http://x.x.x.x:8000/static/'    
    

    In my html -

    
    

    In my views.py -

    return render_to_response('templates/login-register.html', {},
                              context_instance=RequestContext(request));    
    

    nginx inside the sites-available config file -

    listen x.x.x.x:8000;    
    server_name x.x.x.x.;
    

    Restarted nginx
    Restarted apache

提交回复
热议问题