0

I have a Django 1.4 project that makes use of django-registration which calls a redirect('registration_complete', (), {}) after a user registers successfully. This works great on the django development server which runs at http://127.0.0.1:8000/.

My staging site sits at a non-root location on an Apache server. Something like http://example.com/mysite. So when a user registers there, this leads to a page not found error as the django-registration redirect call doesn't reverse the url correctly -- it leaves off the site root (mysite/).

I'm trying to decide how to fix this. Here is what I am considering:

1) Write a custom django-registration backend to handle the registration workflow differently.

2) Patch the django-registration default backend to handle the redirects differently.

3) ?

What is the best way to fix this?

Erik
  • 7,479
  • 8
  • 62
  • 99
  • An example of the redirect that (I think) is causing me pain is in line 190 of this django-registration view code: https://bitbucket.org/ubernostrum/django-registration/src/27bccd108cde/registration/views.py – Erik Apr 19 '12 at 03:53
  • 1
    Does url resolving work in other places? Django usually does not work well with subdirectories so it's better to run project on separate subdomain. – ilvar Apr 19 '12 at 04:40
  • All of my calls to reverse('urlname') leave off the mysite prefix. This has always been a sticking point for me. Using a subdomain for my staging environment is an excellent idea I hadn't considered. – Erik Apr 19 '12 at 05:20
  • If you can use a separate subdomain for Django project - it will be the best solution anyway. – ilvar Apr 19 '12 at 05:23
  • I agree -- an excellent suggestion. Would be nice to know how to reliably get the reverse() to work, but I am working on the subdomain solution now. Thanks! – Erik Apr 19 '12 at 05:33

2 Answers2

0

If you have the registration package as part of you code, then you can just add the prefix where needed in registration urls file. If not, you can add the prefix in your main url and lead it to registration urls with the include statement. Does it help you?

alexarsh
  • 5,123
  • 12
  • 42
  • 51
  • Thanks, but I've moved to using a subdomain per ilvar's suggestion. Seems like a more robust approach. – Erik Apr 21 '12 at 16:05
0

The best solution was that provided by ilvar -- avoid using subdirectories and run the project on a separate subdomain. I'd also suggest putting that subdomain under a different path in the filesystem. Thanks ilvar!

Erik
  • 7,479
  • 8
  • 62
  • 99