WebFaction
Community site: login faq

I had a django app under root directory: mydomain.com

Then I wanted to move this app to a new domain and subdirectory: newdomain.com/d

The app works properly but all the urls are broken. I searched the forums how to solve the problem. I found the topic Django in a sub directory in the webfaction's old forum and Run Django with URL prefix (“subdirectory”) - App works, but URLs broken? in stackoverflow.

The problem in stackoverflow seems more relavant to me. And the proposed solution is described there as follows:

  1. Change current domain to "yourdomain.tld/cflow" in the "sites" framework. It's easy to do using django admin or dumpdata/loaddata manage.py commands.

  2. Looks like your site is using login_required decorator. In that particular case you can add to settings.py:

    LOGIN_URL = '/[prefix]/accounts/login/'

I will implement this solution. But I wonder if there is a simpler way to solve this problem in webfaction because webfaction handles subdirectory redirections transparently for php apps. I wonder if this is also valid for django apps or not?

asked 11 Nov '10, 08:48

mertnuhoglu
284713
accept rate: 0%


Webfaction handles the redirection in the same way for PHP and for Django apps. PHP apps, however, do not normally care about which path they are accessed by, unlike Django apps.

There is indeed a simpler fix for Django - please check the solution described at http://docs.webfaction.com/software/django/config.html#mounting-a-django-application-on-a-subpath

permanent link

answered 11 Nov '10, 08:57

tie
1.4k13
accept rate: 44%

Thank you. I was searching the internet for two hours and I didn't think of looking to the official documentation. :) Being addicted to google...

(11 Nov '10, 09:09) mertnuhoglu

One more question. Indeed, this solved the problem mostly. Only the urls pointing to the images and css are still broken. Should I change their links throughout the source code or is there another simpler solution?

(11 Nov '10, 09:16) mertnuhoglu
1

You have two options - either mount your static application(s) in the Control Panel, so that they match the URL scheme in your source code, or edit your code, so that its URL scheme matches the mount URLs of your static applications.

(11 Nov '10, 09:28) tie
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×225

question asked: 11 Nov '10, 08:48

question was seen: 16,519 times

last updated: 11 Nov '10, 09:28

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM