Question in document "How to use Django with Apache and mod_wsgi"

66 views
Skip to first unread message

Dae_James

unread,
Oct 18, 2012, 9:39:13 AM10/18/12
to django...@googlegroups.com
The url of the document is: https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/
I can't succeed at the last part, "Serving the admin files".  My admin page is as follows.


I have tried two ways. However both can't succeed.
First means is as the following steps:
1, Activate the admin site following https://docs.djangoproject.com/en/1.4/intro/tutorial02/
2, Execute "manage.py collectstatic" in console.
3, Start mob_wsgi.

Second means is as the following steps:
1, Activate the admin site following https://docs.djangoproject.com/en/1.4/intro/tutorial02/
2, Copy the admin files live in (django/contrib/admin/static/admin) into my Apache document root(C:\Program Files\Apache Software Foundation\Apache2.2\htdocs)
3, Start mob_wsgi

Help, please! Thank you~~

Tomas Ehrlich

unread,
Oct 18, 2012, 12:48:47 PM10/18/12
to django...@googlegroups.com
Hello,
have you set proper aliases in apache site config?

Alias /robots.txt /path/to/mysite.com/static/robots.txt
Alias /favicon.ico /path/to/mysite.com/static/favicon.ico

AliasMatch ^/([^/]*\.css) /path/to/mysite.com/static/styles/$1

Alias /media/ /path/to/mysite.com/media/
Alias /static/ /path/to/mysite.com/static/

<Directory /path/to/mysite.com/static>
Order deny,allow
Allow from all
</Directory>

<Directory /path/to/mysite.com/media>
Order deny,allow
Allow from all
</Directory>

or similar. Check that apache can read
directories /path/to/mysite.com/{static,media} ...

You should have appropriate settings in your settings.py, eg.

MEDIA_URL = '/media/'
STATIC_URL = '/static/'

MEDIA_ROOT and STATIC_ROOT aren't important in this case.

Then, take a look at you access.log, if there is something relevant.

Does it works now? If no, please send your settings.py and apache site
config file. (Don't forget to delete sensitive data from settings.py
before posting here).

Cheers,
Tom


Dne Thu, 18 Oct 2012 06:39:13 -0700 (PDT)
Dae_James <daed...@126.com> napsal(a):

> The url of the document is:
> https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/
> I can't succeed at the last part, "Serving the admin files". My admin page
> is as follows.
>
> <https://lh3.googleusercontent.com/-JvizcFwx52s/UIADfuCY-UI/AAAAAAAAAAM/59oDrVVuHzA/s1600/Untitled20121018212559.png>

Dae James

unread,
Oct 18, 2012, 10:02:25 PM10/18/12
to django-users
Thank you. Yes, I didn't set "Alias /static/ /path/to/mysite.com/static/" in my site config.
However, when I set that alias, I met another problem as the following picture. As the picture, my models don't have "Add" and "Change" button, which they have when I run this site on development server or when I just set DEBUG in settings.py to True.
 
 

Dae James
-- 
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
 
Untitled20121019094521.png

Tomas Ehrlich

unread,
Oct 19, 2012, 12:56:17 AM10/19/12
to django...@googlegroups.com
Hello,
sometimes I have similar problem. Usually helps clear cache or reload page (using F5). I'm still not sure why that happens, since both develop and production versions run on different domains (localhost:8000 and mysite.com).

If admin site have proper css style and only images are missing, I don't have a clue what cause it.


Cheers,
Tom


Dne Fri, 19 Oct 2012 10:02:25 +0800
"Dae James" <daed...@126.com> napsal(a):

> Thank you. Yes, I didn't set "Alias /static/ /path/to/mysite.com/static/" in my site config.
> However, when I set that alias, I met another problem as the following picture. As the picture, my models don't have "Add" and "Change" button, which they have when I run this site on development server or when I just set DEBUG in settings.py to True.
>
>
>
>
>
S pozdravem
Tomáš Ehrlich

Email: tomas....@gmail.com
Tel: +420 608 219 889
Jabber: elv...@jabber.cz

"Půjdu kamkoliv, pokud je to kupředu." - J. London
Reply all
Reply to author
Forward
0 new messages