Pure python-alternative to Gunicorn/NGINX/Serving static content
I'm using gunicorn and nginx on ubuntu when deploying my django projects, but now I need to run a project on several platforms, including windows. Is there a similar pure python configuration ( with the expected reduced performance for serving static content )? -- Mvh/Best regards, Thomas Weholt http://www.weholt.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
trouble serving static content within an included javascript libary
Howdy, I'm pretty much a django newbie and can't figure out how to resolve the following issue. I am hosting a local copy of the OpenLayers javascript library and it's associated static content including .png's and .css's. On my file system, the structure is: mapping/static/openlayers.js mapping/static/img/*.png mapping/static/theme/... Internal to OpenLayers, OpenLayers gets images and such using relative paths like "img/whatever.png" and "theme/default/style.css". Notice that these urls are relative to OpenLayers. Within Django, I am using staticfiles and staticfiles_urlpatterns for urls. So within my web page template I can get to OpenLayers just fine via: which resolves to: http://localhost:8000/mapping/static/openlayers.js The problem is that with OpenLayers, the resources referenced by "img/whatever.png" are resolved into http://localhost:8000/mapping/img/whatever.png not http://localhost:8000/mapping/static/img/whatever.png where they would be found. Is there an easy way to fix this? I don't want to move OpenLayers, and I really don't want to have to edit OpenLayers. thanks, Danny -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Serving static content
On Mon, 2009-03-30 at 19:37 -0400, Jack Orenstein wrote: > I have my first Django app running, but with very basic html. I'm > trying to add my first tag and finding it difficult to serve up > the image file. > > I've read this: http://docs.djangoproject.com/en/dev/howto/static- > files/?from=olddocs, which points out that having django serve static > content is "inefficient and insecure", and then points to a reference > for Apache plus mod_python. > > Questions: > > 1) The method outlined above isn't working for me. urls.py says (for > my foobar application): > > (r'^media/(?P.*)$', 'django.views.static.serve', > {'document_root': '/Users/jao/django/foobar/media'}), > > /Users/jao/django/foobar/media/images has xyz.gif, and my page says: > > > > But when I load the page, the image doesn't show up. I get a little > box with a question mark in it. > > > 2) I'm not using mod_python, I'm using mod_wsgi. Is the procedure > pretty close to that of mod_python? Yes. As Graham noted in his reply, the serving of static files is done entirely by the webserver. Although the documentation for this is in the documentation for mod_python, it doesn't actually have anything mod_python-specific about it. The instructions are identical. > > > 3) Why exactly is the builtin django method insecure? Because all software is insecure by default. The media serving code has not been audited for security and if somebody was to report a "security" problem with it, we are going to say it's not intended to be secure. WE are simply not taking on the maintenance burden of maintaining software to do something that dozens of webserver products already do quite well. It's a matter of using the right tool for the job and Django is not the right tool for serving static media (in 98% of cases): it's out of scope intentionally. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Serving static content
On Mar 31, 10:37 am, Jack Orensteinwrote: > I have my first Django app running, but with very basic html. I'm > trying to add my first tag and finding it difficult to serve up > the image file. > > I've read this:http://docs.djangoproject.com/en/dev/howto/static- > files/?from=olddocs, which points out that having django serve static > content is "inefficient and insecure", and then points to a reference > for Apache plus mod_python. > > Questions: > > 1) The method outlined above isn't working for me. urls.py says (for > my foobar application): > > (r'^media/(?P.*)$', 'django.views.static.serve', > {'document_root': '/Users/jao/django/foobar/media'}), > > /Users/jao/django/foobar/media/images has xyz.gif, and my page says: > > > > But when I load the page, the image doesn't show up. I get a little > box with a question mark in it. > > 2) I'm not using mod_python, I'm using mod_wsgi. Is the procedure > pretty close to that of mod_python? If using mod_wsgi you shouldn't be configuring Django to serve the static files, you should be configuring Apache to serve them. See the documentation: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango Graham > 3) Why exactly is the builtin django method insecure? > > Thanks for any help. > > Jack Orenstein --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Serving static content
I have my first Django app running, but with very basic html. I'm trying to add my first tag and finding it difficult to serve up the image file. I've read this: http://docs.djangoproject.com/en/dev/howto/static- files/?from=olddocs, which points out that having django serve static content is "inefficient and insecure", and then points to a reference for Apache plus mod_python. Questions: 1) The method outlined above isn't working for me. urls.py says (for my foobar application): (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': '/Users/jao/django/foobar/media'}), /Users/jao/django/foobar/media/images has xyz.gif, and my page says: But when I load the page, the image doesn't show up. I get a little box with a question mark in it. 2) I'm not using mod_python, I'm using mod_wsgi. Is the procedure pretty close to that of mod_python? 3) Why exactly is the builtin django method insecure? Thanks for any help. Jack Orenstein --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Serving static content using Apache
djandrow wrote: > Managed to get it working, thanks everyone. > > I guess the problem was CSS was missing from locationMatch > --~--~-~--~~~---~--~~ Good news. For what it's worth, when I am serving static content I tend to set whole directories to be served statically rather than limit it to specific extensions by matching. So in my config files I tend to use stuff like SetHandler None SetHandler None and everything from those areas gets served statically. I only have multiple directories because the original design didn't conveniently lump everything under /static/. YMMV, of course, but it's a thought. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Serving static content using Apache
Managed to get it working, thanks everyone. I guess the problem was CSS was missing from locationMatch --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Serving static content using Apache
I've added this, #css has been added to the end SetHandler None but still no luck, however if i look at the pages statically on the server rather than having apache serve them the CSS is used so now I know that the CSS works and i guess its in the right place, although the relative and absolute address are the same, but if thats the case it should work anyway. Does anybody have any ideas? Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: serving static content on Windows
Indeed, the problem was the shortcut! Now, it just works fine. Thanks a lot, Koen André --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: serving static content on Windows
The error message says it all: it is looking for testporject.polls.views.django.views.static. Notice the first part. It means your view function is taken from within testproject.polls.views (which is probably on top in your patterns declaration). You should take this declaration out of there and add it seperately, something like this: urlpatterns = patterns('testproject.polls.views', # your patterns here ) urlpatterns += patterns('',... # the static view here ) Koen On 16 apr, 23:43, "Andre Meyer" <[EMAIL PROTECTED]> wrote: > hi all > > i am new to Django and trying to figure out a few things. so far, everything > looks very nice. > > but now, i am stuck at something very simple: i cannot manage to serve > static content (images, css, dojo, ...) from Django itself. i have done what > is described athttp://www.djangoproject.com/documentation/static_files/and > here is what i get as a response when trying to access some image file from > the appropriate location. > > in urls.py: > *(r'^site_media/(?P.*)$', 'django.views.static.serve', > {'document_root': 'E:\\projects\\django\\testproject\\media', > 'show_indexes': True}), > *http://localhost:8000/site_media/django.gif > ViewDoesNotExist at /site_media/django.gif Could not import > testproject.polls.views.django.views.static. Error was: No module named > django.views.static Request Method: GET Request > URL:http://localhost:8000/site_media/django.gif Exception Type: > ViewDoesNotExist Exception Value: Could not import > testproject.polls.views.django.views.static. Error was: No module named > django.views.static Exception Location: > C:\Python25\Lib\site-packages\django\core\urlresolvers.py > in _get_callback, line 127 > > what is wrong with *django.views.static*? are modifications necessary to > settings.py? i have tried various path syntaxes, but none worked. > > please, let me know what is going on > thanks a lot for your help > André --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
serving static content on Windows
hi all i am new to Django and trying to figure out a few things. so far, everything looks very nice. but now, i am stuck at something very simple: i cannot manage to serve static content (images, css, dojo, ...) from Django itself. i have done what is described at http://www.djangoproject.com/documentation/static_files/ and here is what i get as a response when trying to access some image file from the appropriate location. in urls.py: *(r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': 'E:\\projects\\django\\testproject\\media', 'show_indexes': True}), * http://localhost:8000/site_media/django.gif ViewDoesNotExist at /site_media/django.gif Could not import testproject.polls.views.django.views.static. Error was: No module named django.views.static Request Method: GET Request URL: http://localhost:8000/site_media/django.gif Exception Type: ViewDoesNotExist Exception Value: Could not import testproject.polls.views.django.views.static. Error was: No module named django.views.static Exception Location: C:\Python25\Lib\site-packages\django\core\urlresolvers.py in _get_callback, line 127 what is wrong with *django.views.static*? are modifications necessary to settings.py? i have tried various path syntaxes, but none worked. please, let me know what is going on thanks a lot for your help André --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Serving static content with development server?
Images are uploaded to directory which name is constructed from 2 parts: MEDIA_ROOT + model's upload_to. Then image url gets constructed from MEDIA_URL and upload_to (and image name itself). So if your C:\django\site_media\ is accessible with web-server, and say C:/django/ is DOCUMENT_ROOT of Apache for virtual host django_media.local, and your model has 'upload_to="site_media/"', then images are uploaded to c:\django\site_media\IMG_0394.JPG and are accessible at web as http:\\django_media.local\site_media\IMG_0394.JPG. To access images you should setup separate Apache virtual host, I think. 2007/5/9, gsmith <[EMAIL PROTECTED]>: > > > James, > I use get_image_url and the src is still 'c:/django/site_media/ > IMG_0394.JPG'. I think their is a property that I don't have > correct. Below is a list of properties that might be wrong > > settings.py > > MEDIA_ROOT = '' > MEDIA_URL = '' > > > > urls.py > > (r'^site_media/(?P.*)$', 'django.views.static.serve', > {'document_root': 'c:/django/site_media/', 'show_indexes': True}), > > > > models.py > > class members(models.Model): > title = models.CharField(maxlength=100) > names = models.CharField(maxlength=100) > theslug = models.SlugField(prepopulate_from=["names"]) > email = models.EmailField() > city = models.CharField(maxlength=100) > state = models.USStateField() > image = models.ImageField(upload_to='c:/django/site_media/') > > // > > members_detail.py > > > > > > > Thanks for any help > > On May 8, 10:20 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > > On 5/8/07, gsmith <[EMAIL PROTECTED]> wrote: > > > > > by using the following html ' > > However, this contains the string 'c:/django/site_media/image.jpg'. > > > > Use > > > > > > > > The "get_FIELDNAME_url" method will return the URL of the file > > relative to MEDIA_ROOT, while just printing out the field value will > > return the filesystem location of the file. This is covered in the > > documentation: > > > > http://www.djangoproject.com/documentation/db-api/#get-foo-url > > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > correct." > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Serving static content with development server?
James, I use get_image_url and the src is still 'c:/django/site_media/ IMG_0394.JPG'. I think their is a property that I don't have correct. Below is a list of properties that might be wrong settings.py MEDIA_ROOT = '' MEDIA_URL = '' urls.py (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': 'c:/django/site_media/', 'show_indexes': True}), models.py class members(models.Model): title = models.CharField(maxlength=100) names = models.CharField(maxlength=100) theslug = models.SlugField(prepopulate_from=["names"]) email = models.EmailField() city = models.CharField(maxlength=100) state = models.USStateField() image = models.ImageField(upload_to='c:/django/site_media/') // members_detail.py Thanks for any help On May 8, 10:20 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 5/8/07, gsmith <[EMAIL PROTECTED]> wrote: > > > by using the following html ' > However, this contains the string 'c:/django/site_media/image.jpg'. > > Use > > > > The "get_FIELDNAME_url" method will return the URL of the file > relative to MEDIA_ROOT, while just printing out the field value will > return the filesystem location of the file. This is covered in the > documentation: > > http://www.djangoproject.com/documentation/db-api/#get-foo-url > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Serving static content with development server?
On 5/8/07, gsmith <[EMAIL PROTECTED]> wrote: > by using the following html ' However, this contains the string 'c:/django/site_media/image.jpg'. Use The "get_FIELDNAME_url" method will return the URL of the file relative to MEDIA_ROOT, while just printing out the field value will return the filesystem location of the file. This is covered in the documentation: http://www.djangoproject.com/documentation/db-api/#get-foo-url -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Serving static content with development server?
I have installed the Django Development Server on my computer. I am trying to add some css and images to my project. I'm having problems getting my pictures to upload correctly. Below is the details of some of my files. setting.py MEDIA_ROOT = '' / urls.py (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': 'c:/django/site_media/', 'show_indexes': True}), /// models.py class members(models.Model): title = models.CharField(maxlength=100) names = models.CharField(maxlength=100) theslug = models.SlugField(prepopulate_from=["names"]) email = models.EmailField() city = models.CharField(maxlength=100) state = models.USStateField() image = models.ImageField(upload_to='c:/django/site_media/') When i have 'image = models.ImageField(upload_to='c:/django/ site_media/')' defined I am able to login to my admin and successfully add the image. However, when i go to view the image (in a webpage) in my browser the picture doesn't show up. My template shows the image by using the following html 'http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---