2

So I installed Bitnami Django stack, and enabled the admin module, and followed the tutorial for creating an admin menu for "Polls".

However, when I go to /admin/ everything is white plaintext. All the css and images are 404 error.

All I did was:

enable in settings.py installed_apps:

'django.contrib.admin',

In urls.py UNcommented:

from django.contrib import admin
admin.autodiscover()
url(r'^admin/', include(admin.site.urls)),

uncommented.

In settings.py, I tried using default settings and also tried this:

MEDIA_ROOT = ''
MEDIA_URL = '/media/'
STATIC_ROOT = ''
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'
import os
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
STATICFILES_DIRS = (
  os.path.join(SITE_ROOT, 'static/'),
)

Nothing seems to work, it refuses to find static files in /admin/media/css/ etc.

I made sure my windows PATH has /bin of django. I even tried including /contrib, nothing helps.

I have installed Django to: C:\DjangoStack\apps\django

I have installed my project to: C:\Users\dexter\BitNami DjangoStack projects\Alpha and I type: localhost/Alpha/admin to go to admin.

Dexter
  • 6,170
  • 18
  • 74
  • 101
  • do you have a copy of the django admin css and image stack in static/admin ? It shouldn't matter on local host, but it is something to try... – Daniel Nill Oct 05 '11 at 18:41
  • No I don't know where static/admin is. – Dexter Oct 05 '11 at 18:42
  • static admin is a folder you create insite your project, same as your media folder. You should have `project/media`, `project/static` and `project/static/admin`. Go into your Django installation and make a copy of the admin media folder, it should look something like 'admin/css`, `admin/js`, and `admin/images`. And copy that into your `static/admin` folder. But like I said this shouldn't matter on local host. You might also just check to see if changing your `staticfiles_dirs` to `()`. And I guess I should have just put this as an answer... – Daniel Nill Oct 05 '11 at 18:48
  • Everything is still white and 404. Debug says it looks for for example localhost/static/admin/css/ie.css 404. I also tried to point my browser to localhost/Alpha/static/admin/css/ie.css doesn't work. I also tried localhost/Alpha/Gamma/static/admin/css/ie.css (Gamma is my little poll app), that doesn't work either. – Dexter Oct 05 '11 at 18:51
  • The error I get: Using the URLconf defined in Alpha.urls, Django tried these URL patterns, in this order: ^admin/ The current URL, static/admin/css/ie.css, didn't match any of these. – Dexter Oct 05 '11 at 18:58
  • @DanielNill: You aren't supposed to add anything to static/ on your own. That directory is merely a dumping ground for the collectstatic management command. – Chris Pratt Oct 05 '11 at 19:45
  • @chrisdpratt - I understand that but to my understanding, that is kind of an arbitrary regulation. And since they had their admin folder in their static fold and here having trouble I figured it might be a jerry-rig solution. It's one thing that has worked for me in the past when I run into this problem setting up a live server. – Daniel Nill Oct 05 '11 at 21:36

2 Answers2

4

I almost missed the answer to this until I re-read your question and finally caught the bit in the last line: "and I type: localhost/Alpha/admin to go to admin". That means all your URL settings are wrong.

Currently, you have:

MEDIA_URL = '/media/'
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

Whereas, these should be:

MEDIA_URL = '/Alpha/media/'
STATIC_URL = '/Alpha/static/'
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

Additionally, you don't need "static/" in STATICFILES_DIRS. So remove that setting.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • Ah beautiful you figured it out. I don't know why django installation or bitnami installation doesn't already set this up correctly. So weird. – Dexter Oct 05 '11 at 21:10
1

I'm from the BitNami Team and I just saw this issue. I'm not sure if you are using and older version but at least in the newer version of the BitNami DjangoStack you just need to make sure that the ADMIN_MEDIA_PREFIX point to /static/admin/ if you are following the instructions in https://docs.djangoproject.com/en/1.3/intro/tutorial02/ . You don't need to copy the static files in your project directory because django automatically will use the files in django/contrib directory.

However currently we are setting the ADMIN_MEDIA_PREFIX to /static/admin/media because the behavior is different when the application is served by Apache instead of the django server. We realize that this may be a bit confusing for users that are just starting with django and we are looking at this on our side to keep the default configuration for the new projects but also allow the demo project to be served by Apache.

kaysa
  • 1,491
  • 13
  • 9
  • I was using bitnami-djangostack-1.3-0-windows-installer.exe . But I don't know, I might have messed it up by having to do some uninstalling of python 2.7, and then reinstalling bitnami, and maybe something went wrong---the instructions were not clear that Python 2.7 should be removed BEFORE installing bitnami, otherwise conflicts arise. So maybe I messed something up. --- Yes right now everything is confusing to me, I found installing PHP + apache is so much simpler process (because maybe I'm use to it), and I am an experienced .NET / PHP / C++ / C# / assembly developer. Thx for clarifying. – Dexter Oct 11 '11 at 20:36
  • I'm sorry you found issues with an already installed version of Python. We will fix it so it doesn't interfere. – kaysa Oct 18 '11 at 15:29
  • Thank you, and can you tell me if there is a solution to this? http://stackoverflow.com/questions/7851429/bitnami-django-solution-to-restarting-service – Dexter Oct 21 '11 at 15:16