WebFaction
Community site: login faq

Summary: with nearly identical settings, test.mydomain.com gets correct admin media while www.mydomain.com does not.

Detail: I have two subdomains, test.mydomain.com and www.mydomain.com. Their settings.py files are identical, except where the full URLs are relevant. The www subdomain has this:

ADMIN_MEDIA_PREFIX = "http://www.mydomain.com/static/admin/"

While the test subdomain has this:

ADMIN_MEDIA_PREFIX = "http://test.mydomain.com/static/admin/"

The two settings files also point to different template directories -- which works fine. The two subdomains share a common database.

I have a symlink application created which links django_admin_media -> /home/myaccount/webapps/django/lib/python2.5/django/contrib/admin/media/ -- and the link works fine when I follow it at the console.

That application appears in the Webfaction control panel as django_admin_media, and I have it added to a website named mydomain, in which the following subdomains are enabled: mydomain.com, myaccount.webfactional.com, test.mydomain.com, and www.mydomain.com, listed in that order.

When I load test.mydomain.com, the site requests admin media from, for example, "/media/css/base.css", which is not what the settings tell it to. I am pretty sure that's what Django does if ADMIN_MEDIA_PREFIX is not set at all. When I load www.mydomain.com, the site requests admin media from "css/base.css", i.e. a relative path. This is even stranger, because it makes it look like ADMIN_MEDIA_PREFIX is not set AND no default value happens.

Since test.mydomain.com is requesting the admin media from /media/ instead of ADMIN_MEDIA_PREFIX, I mapped the symlink application to /media on the "mydomain" website. That way, at least test.mydomain.com has the correct admin media. And yes, http://www.mydomain.com/media/css/base.css links to the correct media as well.

I'm sure I'm doing something wrong, but why would I be getting different results when the two subdomains are configured almost identically?

asked 11 Jun '11, 19:05

amacdougall
313
accept rate: 0%

edited 11 Jun '11, 19:09


Since your settings look correct, is it possible that you have not restarted your Apache server which is serving the django application? When settings changes are made, it is necessary to restart the Apache server to pick up those changes.

You can do that using the ./apache/bin/restart command from the root directory of your application.

permanent link

answered 11 Jun '11, 19:29

ryans ♦♦
5.0k93260
accept rate: 43%

Wow. On one hand, I feel stupid that I didn't think of such a classic solution ("have you tried turning it off and then on again?") But on the other hand, it feels weird to me that a framework written in a dynamic language wouldn't detect a config file change automatically. Either way, thank you very much. I've been able to work, but this issue has been a nagging thorn in my side.

Edit: also, thank you for working on the weekend! I honestly wasn't expecting an official response so soon. I've severely underutilized my webfaction account, but I've found your support and tutorials very useful.

(12 Jun '11, 21:01) amacdougall

Ah, the restart is necessary because it's running on mod_wsgi under Apache, which caches everything to make it run a lot faster. If you were running this off of the Django Development Server (the 'manage.py runserver' feature) no restart is necessary, but that's not fit for a production environment, and also can have differences from WSGI when you deploy your website live.

As for our support - we're here 24/7/365. Ask us anything, any time :)

(12 Jun '11, 21:15) ryans ♦♦
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
×76
×40
×26
×16

question asked: 11 Jun '11, 19:05

question was seen: 3,082 times

last updated: 12 Jun '11, 21:27

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