On Sun, Feb 1, 2009 at 9:04 AM, Robert <[email protected]> wrote: > > I have set up apache with mod_python and I am able to get django > working. > > I am trying to reach the simple poll application that is in the > djangoproject tutorial. > > I have to add "mysite" in the url when I work with apache. This wasn't > the case with the django server. >
You have to add mysite to the URLs in order for the request to be routed to Django? That sounds like you have put '/mysite/' in the Location block that you added to your Apache config for Django. Is that correct? If so, that tells Apache you want to route only URLs that start with /mysite/ to mod_python, so, yes, you would need to include /mysite/ at the beginning of the URL if you want it to be handled by your Django code running under mod_python. > > http://localhost/mysite/polls/ > > gives the django error message: > > Using the URLconf defined in mysite.urls, Django tried these URL > patterns, in this order: > [..] > The current URL, /mysite/polls/, didn't match any of these. > For future reference, including list of URLs printed by the message wouldn't hurt. In this case I can probably guess what they were, but it is usually better to include the full text of error messages and tracebacks (or point to them on somplace like dpaste.com). So, the problem is you need to add /mysite/ at the front of the URLs in order to get the request routed to mod_python/Django, but the Django URL configuration doesn't include the /mysite/ part so it cannot figure out what to do with the request. > I have tried to change the urls in urls.py but this will lead to other > errors down the road. Is it possible to handle this differently? > Yes, there are two ways to fix this without changing your URL configuration. First -- do you really want Apache to route only URLs that start with /mysite/ to mod_python/Django or would you actually prefer Apache to route everything (minus perhaps some specific prefixes for static files) to mod_python/Django? I have a feeling you may have put the /mysite/ in the Location block because that is what is in the sample provided in the docs. If that is the only reason it is there, and you are really planning on your entire site to be served by Django code, then you can just change the Location block to <Location "/"> and you will no longer need to prepend /mysite/ to the URLs. If you do, however, only want a subset of your site's entire URL tree to be routed by Apache to mod_python/Django, then you can leave the <Location "/mysite/"> as it is, and add a django.root PythonOption as described here: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#basic-configuration > > This is my pythonpath in httpd.conf: > PythonPath "['c:/Pythonprojects'] + sys.path" > This is the reference to the settings: > SetEnv DJANGO_SETTINGS_MODULE mysite.settings > The fact that the request got as far as failing to match anything in your url configuration implies these settings are fine. The first setting ensures that the Python interpreter can find your code, and the second ensures that Django code, when it gets control, can find your project settings. Your code and settings had to have been found for the request to get as far as it did, and neither has anything to do with URL routing (except indirectly, as your settings points to your url config). (I'm not trying to be annoying here -- I'm just pointing this out in an effort to help you see how all the pieces of the various config settings fit together.) Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

