i've had some strange errors when trying to install django standalone, so i have used the whole bundle option, linked from documentation. Bitnami. It installed python, django, apache, sqlite.... I use Windows XP btw.
And i've went first run on python and django by the tutorial. Unfortunatly i have stopped at part 2 when i should login to admin panel, and can't solve problem with css and js files.开发者_Python百科 They just don't load, do a 404 and i see admin panel in a pure html layout (scary).
So how could i fix this? My settings.py and urls.py are all default, except i turned on all those apps that tutorial said to and admin url.
I see that the css and js files lies in their folders under this path:
C:\Program Files\BitNami DjangoStack\apps\django\django\contrib\admin \media
While my app(models, views,tests) is here:
C:\Documents and Settings\Luka\BitNami DjangoStack projects\djangoTut \polls
and settings.py is one folder up
How should i configure and what to make those damn css load?
Well, simply put, read here: https://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/#serving-files
You have to(see doc):
Create a symbolic link to the admin static files from within your document root. Or, copy the admin static files so that they live within your Apache document root.
and fiddle your apache/nginx configuration a bit!
To give you an example with my config, but btw, I'm not using django 1.3 ... so no django.contrib.staticfiles
. But the differences aren't that big:
Apache:
<Directory "D:/projects/my_project/src">
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias /my_project D:/projects/my_project/src/django.wsgi
Alias /media/ "D:/projects/my_project/media/"
Alias /static-media/ "D:/projects/my_project/media-static/"
<DirectoryMatch "D:/projects/my_project/media/">
Order allow,deny
Allow from all
</DirectoryMatch>
settings.py
MEDIA_ROOT = 'D:/projects/my_project/media/'
STATIC_MEDIA_URL = '/static-media/'
MEDIA_URL = '/media/'
ADMIN_MEDIA_PREFIX = '/static-media/admin/'
Now you either copy the admin static files to the defined static-media location, or you symlink it! https://stackoverflow.com/questions/46885/how-to-create-symbolic-links-in-windows, but you probably end up copying!
Usefull link, if you enjoy reading:
- http://www.muhuk.com/2009/05/serving-static-media-in-django-development-server/
- https://docs.djangoproject.com/en/dev/howto/static-files/
Also, instead of creating symbolic links you can point the Alias in the apache configuration file directly to the django files:
Alias /static-media/ "C:\Program Files\BitNami DjangoStack\apps\django\django\contrib\admin \media"
If you installed the latest version of BitNami Django Stack (I'm a BitNami developer and we recently released a fix for something related to this), and you selected to create a default project you can take a look at the .wsgi file for that project.
精彩评论