Sunday, April 20, 2014

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

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

On Sun, Apr 20, 2014 at 9:19 AM, Adam Teale <adamteale@gmail.com> wrote:
> 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
>
> --
> 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+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@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.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/CABoKswiPe%2BJqz58zG5uiBHA%2Bha6UOuMcaXMDj9acw36LAwk1Eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment