I am a newbie to Django and web development in general, and I've
completed the django tutorial and am working my way through the
practical django projects book. I have a simple app that I wanted to
try out: basically a form in HTML that takes inputs, reads a database,
calculates and displays an output. I just want to 'get' it, for now.
The goal is to dive in and try to execute a very basic app myself.
I'm running everything on windows: Apache 2.2, Django 1.3, Python 2.7
and Postgres 0.9. The django website recommends I go with mod_wsgi. I
installed it in my Apache folder. My django folder is c:/djangostuff.
All the projects/apps I've gone through so far are from this
directory. I made some changes to my httpd.conf file and created a
file called myapp.wsgi in c:/djangostuff, and also in apache2.2/htdocs
From my browser, localhost/myapp.wsgi returns "Hello World!", from
which I gather it's working, whatever it is. But localhost is pointed
at apache2.2/htdocs in the document root setting of my httpd.conf
file. When I try http://127.0.0.1:8000/myapp.wsgi , I get a Page not
found 404 error.
I have gone through the django project website here:
https://code.djangoproject.com/wiki/django_apache_and_ and themod_wsgi
wsgi instructions for django here: http://code.google.com/p/modwsgi/wiki/ .IntegrationWithDjango
I've read up on as many articles on wsgi as I can, and the more I
read, the more it confuses me. My questions:
1. I gather WSGI is an interface that is required to pass data between
django/python and Apache, but the hell is it, really?
2. What is a .wsgi file, and in which directory does it go in? Once it
goes in that directory, how does it work?
3. Once I've created a form in Django, how do I use wsgi to pass data
to the application, and back?
4. Why does the instructions at modwsgi mention I store my django.wsgi
under an apache subdirectory? Why is it that my hello world example
works under localhost but not from http://127.0.0.1:8000/myapp.wsgi ?
My questions are probably stupid, but I have spent the last three days
reading and I still can't figure out how to proceed. I would
appreciate any explanation that helps me 'get' it. Thanks in advance!
You've misunderstood the point of the .wsgi entry. You're not supposed to point your browser at that as a URL. Rather, you use the WSGIScriptAlias directive to send all requests to certain URLs through that script. Typically you'd map the root path, /, to that, although you can mount the script at any point if you want it to only serve certain paths.
As to what it does and how does it work, well all that's covered in the WSGI spec and the mod_wsgi documentation, but from your point of view, your summary is pretty much all you need to know.
Once the WSGIScriptAlias is correct, that's it - you don't need to interact with WSGI any more. You certainly don't need to worry about how to pass data from a Django form: Django itself takes care of that.
--
DR.
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/NoqdeeNhVIIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment