django, mod_wsgi, apache and sharing media files (video) from a separate directory

22 views
Skip to first unread message

Adam Teale

unread,
Apr 20, 2014, 10:19:10 AM4/20/14
to django...@googlegroups.com

Hi Guys,


I am building a django app that runs out of my /Users/me/Dropbox directory.


Localhost is pointed at my /Users/me/Sites directory.


mod_wsgi installed.

apache installed

django installed and app working fine in development mode


I am trying to embed media in a template

This media comes from a directory outside of the django app - in the root of the machine - /PROYECTOS


The permissions for the directories and preceding directories are readable by _www


I think that I understand that

- mod_wsgi will serve the dynamic files

- apache will serve the static files like the css and template files, as well as the media files I am referencing in the /PROYECTOS directory


I have the following in my settings.py:

STATICFILES_DIRS = (os.path.join(BASE, "static"), )

STATIC_URL = "/static/"

MEDIA_URL = "/PROYECTOS/"

WSGI_APPLICATION = 'mbrain.wsgi.application'


In the /etc/apache2/extra/vhosts/localhost.conf I have:


<VirtualHost *:80>


DocumentRoot "/Users/me/Sites/localhost"

ServerName localhost


WSGIDaemonProcess localhost python-path=/Users/me/Dropbox/mBrain_Adam/mbrain/:/Users/me/Dropbox/mBrain_Adam/mbrain/venv/include/python2.7

WSGIProcessGroup localhost


Alias /proyectos/ /PROYECTOS/


<Directory /PROYECTOS>

Require all granted

</Directory>


WSGIScriptAlias / /Users/me/Dropbox/mBrain_Adam/mbrain/mbrain/wsgi.py


<Directory /Users/me/Dropbox/mBrain_Adam/mbrain/mbrain>

<Files wsgi.py>

Require all granted

</Files>

</Directory>


</VirtualHost>


So to embed a media file in a template I have this as the url:

{{ MEDIA_URL }}{{ asset.assetPath }}


When I load the page in a browser the console shows the fully expanded path for the media asset but with a 404 error - HTTP/1.1" 404 3045.


I’d really appreciate any feedback on whether I am approaching this the right way or if I have completely missed the concept.

Also any help on that 404 error would be appreciated.


Cheers!


Adam

Ramón Carrillo

unread,
Apr 20, 2014, 11:49:17 PM4/20/14
to django...@googlegroups.com
Hi Adam,

From your settings.py I guess the expanded url is something like
/PROYECTOS/file.xyz, right?

But, in your Apache alias your are serving the url /proyectos/ [0],
and urls are case sensitive unless you're using mod_speling [1].

I think "Alias /PROYECTOS/ /PROYECTOS/" should do the trick.

[0] http://httpd.apache.org/docs/2.4/mod/mod_alias.html#alias
[1] http://httpd.apache.org/docs/2.4/mod/mod_speling.html
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e6294564-01f1-449c-8cfb-e8dd474bda0b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages