It should be going to .com/helpdesk/support/case/1/ But it's going
to .com/support/case/1/
I'm sure it's something simple as I've had the problem in the past and
fumbled my way through it. But I can't find it this time. Hopefully
the below pasted lines show all the necessary detail.
Anyone see my error?
helpdesk.urls:
urlpatterns = patterns('',
(r'^support/', include('helpdesk.support.urls')),
)
helpdesk.support.urls:
urlpatterns = patterns('helpdesk.support.views',
(r'^case/(?P<case>\d+)/$', 'case',{},'case_url' ),
)
helpdesk.support.views:
def case(request, case):
return HttpResponseRedirect(reverse('case_url', args=(case.id,)))
# Redirect back here after POST
-Shane
How are you tacking the "/helpdesk" to your request initially?
My settings.py has:
#
ROOT_URLCONF = 'helpdesk.urls'
#
INSTALLED_APPS = (
#
'helpdesk.support',
#
)
If I manually key in example.com/helpdesk/support/case/1/ it renders
the correct view. It's only on the redirect that I'm having trouble.
I've got django installed as an app at example.com/helpdesk/ so it's
not on the root. And I suspect this is related to the cause. But I
can't find where.
What I can't wrap my head around is that the url works when keyed in,
but won't reverse to the same thing.
...reverse('case_url', kwargs={'case':case.id})...
Bill
> --
>
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>
>
I'm pretty sure this is because I installed Django to be served not
from the root, but rather from /helpdesk/. I use WebFaction as a
host, and their control panel is where this is setup. I think it uses
SymLinks to direct the shared Apache to the private one that only
serves my Django app. But I'm not sure and can't find a way to tell
for sure. There's nothing currently in the any of the Django files
that refers to /helpdesk/ as part of the url. Yet the webserver
resolves it properly with /helpdesk/ there and not without it.
So I think that the first Apache server is resolving the /helpdesk/
portion of the url and then forwarding everything after that to be
handled by Django. So maybe django doesn't know about /helpdesk/
internally.
Surely I'm not the only person who setup django to serve from a sub
url. And WebFaction is a popular Django host. There must be some
simple setting I'm missing somewhere. Does anyone know what it is?
Thank you in advance.
On Dec 30 2009, 11:37 am, Bill Freeman <ke1g...@gmail.com> wrote:
> Since your urlconf is passing "case" as a named (keyword) argument, you
> (may) have to pass it that way to reverse:
>
> ...reverse('case_url', kwargs={'case':case.id})...
>
> Bill
>
The behavior also happens when I use the URL tag in a template like
this "{% url case_url case.id %}" the result I get is "/support/case/
1/ ".
So the inconsistency is that when I make a request for "http://
www.example.com/helpdesk/support/1/" django is correctly mapping to
the "case" view. But while processing the "case" view and explicitly
naming the "case_url" that points to it, any reverse lookups are not
returning the correct URL.
To me it looks like a bug since I would think it would work both ways
or neither.
I think it may have to do with my switch to django 1.1.1 and mod_wsgi
from an older 1.x version with mod_python.
When using mod_python, this was handled like so:
<Location "/mysite/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
</Location>
But according to this: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
"Note that the django.root option introduced in Django 1.0 alpha
versions does not apply to mod_wsgi and is only necessary with
mod_python, due to mod_python not setting SCRIPT_NAME correctly. "
So where does that leave us? does mod_wsgi need some other
configuration?
I'd suggest to read this recent django-users thread:
http://groups.google.com/group/django-users/browse_frm/thread/ce1436670a3c55d5?hl=en
that point to this Django ticket:
http://code.djangoproject.com/ticket/9435
Another suggestion: Ty dropping the project name from all the imports
and view names
when setting your mod_wsgi deployment, just make sure themodules containing your
settings.py, urls.py and all your apps are in the python module search path.
HTH,
--
Ramiro Morales | http://rmorales.net
Either way. I'm going to drop this for now and see what happens with
the ticket that was opened. It seems like this would be a very big
issue if everyone using mod_wsgi had problems when using django from
anywhere other than the root url. But there are few posts about it.
So I'm going to start over and see if I missed something critical in
my setup.
Thank you -Shane
On Jan 3, 3:01 pm, Ramiro Morales <cra...@gmail.com> wrote:
> http://groups.google.com/group/django-users/browse_frm/thread/ce14366...
Ramiro, thanks for the links. That other thread does seem to describe
the same problem and results in it being identified as a bug in the
core urlresolvers. Unfortunately the work around of "RewriteRule ^/
studio$ /studio/ [R] " doesn't work for me for some reason. Maybe I'm
misapplying it.
Either way. I'm going to drop this for now and see what happens with
the ticket that was opened. It seems like this would be a very big
issue if everyone using mod_wsgi had problems when using django from
anywhere other than the root url. But there are few posts about it.
So I'm going to start over and see if I missed something critical in
my setup.
When I use this test script in the wsgi file I get an empty string as
the value for SCRIPT_NAME. And from what I gather that's where /
helpdesk should be so it can be passed to django so it's aware of the
full path.
**************
import cStringIO
def application(environ, start_response):
headers = []
headers.append(('Content-Type', 'text/plain'))
write = start_response('200 OK', headers)
input = environ['wsgi.input']
output = cStringIO.StringIO()
keys = environ.keys()
keys.sort()
for key in keys:
print >> output, '%s: %s' % (key, repr(environ[key]))
print >> output
output.write(input.read(int(environ.get('CONTENT_LENGTH', '0'))))
return [output.getvalue()]
*****************
So it may not be as much a django issue as an apache/wsgi one. I'm
not skilled enough to make that distinction though. For now I'm just
going to serve the app from the root and move it when I learn more or
the issue is fixed.
I tested the admin module and I get the same problem. Wherever the /
helpdesk is present in the URL everything serves properly. But when I
post a form, it's dropped from the path and I get "There is no
application mounted at the root of this domain. " because I have
nothing mounted at the root. I assume that message is served by
apache.
My host Webfaction uses multiple apache applications where the first
one is shared for the server. I don't get direct access to the
settings for this. Only control panel access which may make some
changes indirectly. I think it uses <Location> settings or maybe
SymLinks? to forward the request to another instance of apache that is
installed with Django on my share of the server. I have total control
of that apache. So, perhaps the first apache isn't passing any value
to the second one to indicate the first "mount point" is present.
This would be the "SCRIPT_NAME" from what I gather.
Yet another manifestation of the issue can be found by leaving off the
trailing slash at the end of the url : example.com/helpdesk/support/
case/1 will automatically redirect to example.com/support/case/1/ as
django adds the slash but drops the /helpdesk
...com/helpdesk results in "There is no application mounted at the
root of this domain. "
....com/helpdesk/ renders the app since my root urls.py contains "(r'^
$', 'helpdesk.support.views.home')," to call the support app home
view.
I hope some of this information helps. In the mean time all the work
I've had to do to "move" my code to the root has completely convinced
me of the wisdom of decoupling. ;-) And at the same time the reason
I'm even having the trouble is because of the use of functions like
reverse to avoid hard coding views and templates to urls!
Thanks for your feedback.
On Jan 3, 5:50 pm, Karen Tracey <kmtra...@gmail.com> wrote:
On Jan 4, 12:45 pm, davathar <davat...@gmail.com> wrote:
> Here's more information I've been able to find. Evidently there's a
> problem in some configurations wheremod_wsgieither isn't receiving
Unless you are on an old server build, WebFaction uses nginx as front
end, not Apache.
In either case, the front end mount point isn't passed across. For it
all to work properly, the front end mount point must match the backend
mount point. You cannot mount on front end as /helpdesk and then have
it proxy to / on backend for example. The backend must be mounted at /
helpdesk as well.
In respect of prior discussion, did you disable mod_rewrite in backend
Apache?
Graham
> Yet another manifestation of the issue can be found by leaving off the
> trailing slash at the end of the url : example.com/helpdesk/support/
> case/1 will automatically redirect to example.com/support/case/1/ as
> django adds the slash but drops the /helpdesk
>
> ...com/helpdesk results in "There is no application mounted at the
> root of this domain. "
>
> ....com/helpdesk/ renders the app since my root urls.py contains "(r'^
> $', 'helpdesk.support.views.home')," to call the support app home
> view.
>
> I hope some of this information helps. In the mean time all the work
> I've had to do to "move" my code to the root has completely convinced
> me of the wisdom of decoupling. ;-) And at the same time the reason
> I'm even having the trouble is because of the use of functions like
> reverse to avoid hard coding views and templates to urls!
>
> Thanks for your feedback.
>
> On Jan 3, 5:50 pm, Karen Tracey <kmtra...@gmail.com> wrote:
>
>
>
> > On Sun, Jan 3, 2010 at 5:15 PM, davathar <davat...@gmail.com> wrote:
> > > Ramiro, thanks for the links. That other thread does seem to describe
> > > the same problem and results in it being identified as a bug in the
> > > core urlresolvers. Unfortunately the work around of "RewriteRule ^/
> > > studio$ /studio/ [R] " doesn't work for me for some reason. Maybe I'm
> > > misapplying it.
>
> > > Either way. I'm going to drop this for now and see what happens with
> > > the ticket that was opened. It seems like this would be a very big
> > > issue if everyone usingmod_wsgihad problems when using django from
So, please post the actual Apache configuration snippet you are using
to map you Django application with mod_wsgi so can verify that the
configuration you are using is in fact correct.
Normally WebFaction recipes should create it correctly, but if you
have hand crafted it and followed one of the incorrect blog posts out
there about it, you could have problems.
Graham
On Jan 4, 6:23 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote: