[Python-il] [pyweb-il:315] Removing prefix from url.

Saffi saffi.h at gmail.com
Tue Jul 28 13:17:11 IDT 2009


Yesterday Ofri and I talked about the Kneset project.  It reminded me an
issue we had.
The site url seems different with "runserver" then through the apache. when
I run the ./manage.py the request url is processed according to the urls.py.
example:
http://127.0.0.1:8080/ping/

for detecting it is django we used /serve/ as url (our project is also
called serve). but while running the server in standalone it had no
meaning.

http://myapache:80/serve/ping/
but that can't work since my django does not know the /serve/
We want to swallow that "/serve/" prefix so everything would be as "usual"
thought the url is a bit different.

so in settings.py we directed to a different urls.py

# ROOT_URLCONF = 'serve.urls'
# skip the prefix /serve/
ROOT_URLCONF = 'serve.prefixurls'

which in turns delegated to the usual urls.py
# prefixurls.py
import os
from django.conf.urls.defaults import *
from django.conf import settings
import serve.proxy.views
urlpatterns = patterns('',
             (r'^serve/', include('serve.urls')),
    )


Now the standalone server:
example:
http://127.0.0.1:8080/serve/ping/
and the apache
http://myapache:80/serve/ping/



Saffi & Ze'ev

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "PyWeb-IL" group.
To post to this group, send email to pyweb-il at googlegroups.com
To unsubscribe from this group, send email to pyweb-il+unsubscribe at googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyweb-il?hl=en
-~----------~----~----~----~------~----~------~--~---

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://hamakor.org.il/pipermail/python-il/attachments/20090728/7e1108d3/attachment.htm 


More information about the Python-il mailing list