My urls.py file is (I only used the non-testing part):

from django.conf.urls.defaults import *

urlpatterns = patterns('',
  ('', url(r'^~mysite/', include('mysite.mysiteurls'))),
)

And my mysiteurls.py file:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
  url(r'^admin/', include('django.contrib.admin.urls')),
  url(r'^', include('lsjumb.main.urls')),
)

>Django strips the domain part (and the GET parameters), leaving
>'~mysite/index/' as what to match (unless somebody else on this list
>corrects me, but I didn't found this documented). So you'll need to
>take out the ~mysite yourself, which is what urls.py does

I'm not sure my setup works exactly like this. Using my old urls.py, I
would navigate to http://www.university.edu/~mysite/admin/ with the
regex ^admin/. When I changed the regex to ~mysite/admin/, it no
longer finds the page. A curious thing is that on the Django 404 page,
the request URL is listed as http://www.university.edu/admin/ instead
of http://www.university.edu/~mysite/admin/ (I don't know if this is
relevant, but I have no idea what is causing the problem). It could be
because my setup uses fastcgi to redirect nonexisting pages (ie, not
media pages) in the /~mysite/ folder to Django to deal with (I used
the directions here:
http://www.djangoproject.com/documentation/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache).

On Apr 3, 2:47 am, Evert Rol <[EMAIL PROTECTED]> wrote:
> > I tried doing what you suggested, but now it gives me the error
> > 'RegexURLResolver' object has no attribute 'rindex' when I try to go
> > to the admin page (or any page that exists, for that matter. Pages
> > that don't exist get an unhandled exception).
>
> Can you show us your url setup as you have it now? It may be something
> else.
>
>  From a quick Google, it may also be a problem depending on the Django
> version; which version are you using?
>
> > Also, I'm not sure if your solution will fix my problem. Django should
> > never receive the /~mysite/ part of the url becuase its root is that
> > folder (ie,http://www.university.edu/~mysite/index/is seen in Django
> > as /index/).
>
> Django strips the domain part (and the GET parameters), leaving
> '~mysite/index/' as what to match (unless somebody else on this list
> corrects me, but I didn't found this documented). So you'll need to
> take out the ~mysite yourself, which is what urls.py does (though the
> media url setting would need to be adjusted for that).
> I'm doing exactly the same thing as you, other than that my 'prefix'
> isn't precisely ~mysite, but I'm still stripping it out before
> matching for views. Works for me.
>
> >>> I'm trying to set up my site on a university webspace, so the root
> >>> is
> >>> a subdirectory, iewww.university.edu/~mysite/. Because of this, I'm
> >>> having trouble logging into the admin pages. I go
> >>> towww.university.edu/~mysite/admin/
> >>> and get the login page, but when I try to login, it goes to
> >>>www.university.edu/admin/becausethe form posts to the relatvie
> >>> url /
> >>> admin/. Any ideas how to fix this? Anyone else have this problem?
>
> >> Not a problem to me really, as here's how I fixed it:
>
> >> urls.py:
>
> >> from django.conf.urls.defaults import *
> >> from django.conf import settings
> >> import sys
>
> >> if 'runserver' in sys.argv:
> >>     urlpatterns = patterns('',
> >>         # special URLs
> >>         (r'^mysitemedia/(?P<path>.*)$', 'django.views.static.serve',
> >>          {'document_root': settings.MEDIA_ROOT}),  # This may have to
> >> be different, eg '^~mysite/media/' or so (but be careful the admin
> >> and
> >> your own media don't clash).
>
> >>         # normal URLs
> >>         url(r'^~mysite/', include('mysite.mysiteurls')),   # Here, I
> >> pick out the base url
> >>                            )
> >> else:
> >>     urlpatterns = patterns('', url(r'^~mysite/',
> >> include('mysite.mysiteurls')),)
>
> >> and mysiteurls.py:
>
> >> from django.conf.urls.defaults import *
>
> >> urlpatterns = patterns('',
> >> # special URLs
> >>     (r'^admin/', include('django.contrib.admin.urls')),
>
> >> # normal URLs
> >>     url(r'^users/', include('mysite.users.urls')),
> >>     .
> >>     .
> >>     .
> >>     url(r'^', include('mysite.main.urls')),
> >> )
>
> >> Lastly, in settings.py, I have defined a ROOT_URL and some
> >> redefinitions for the user stuff:
> >> ROOT_URL = '/~mysite/'
> >> LOGIN_URL = ROOT_URL + 'users/login/'
> >> LOGOUT_URL = ROOT_URL + 'users/logout/'
> >> LOGIN_REDIRECT_URL = ROOT_URL + 'users/profile/'
>
> >> Note: I have put '~mysite' in various places, but since I actually
> >> simply use 'mysite', I may have done some incorrect substitutions. So
> >> do doublecheck.
> >> But in principal this should work, and with the proper setup for the
> >> media, you can use the same url configuration for a development and
> >> production server.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to