Django urls problem:It works! ... You're seeing this message because you have DEBUG = True in your D

From:http://stackoverflow.com/questions/4172650/django-admin-page-not-showing

5
down vote
favorite
1
I've been following the polls tutorial up until the point where I should have a login page for the admin backend. http://docs.djangoproject.com/en/dev/intro/tutorial02/ 

Instead I get the welcome page like this:

It works! ... You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!
I have enabled the admin app in INSTALLED_APPS, synced the db and tweaked urls.py so I'm not sure what the problem is.

Running apache2 with mod_wsgi.

urls.py: from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
 from django.contrib import admin
 admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^testproject/', include('testproject.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
     (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
     (r'^admin/', include(admin.site.urls)),
)
Settings.py:

...
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    # Uncomment the next line to enable the admin:
     'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
     'django.contrib.admindocs',
     'polls'
)
...
Tables:

Database changed

mysql> SHOW TABLES;
+----------------------------+
| Tables_in_django_test      |
+----------------------------+
| auth_group                 |
| auth_group_permissions     |
| auth_message               |
| auth_permission            |
| auth_user                  |
| auth_user_groups           |
| auth_user_user_permissions |
| django_admin_log           |
| django_content_type        |
| django_session             |
| django_site                |
| polls_choice               |
| polls_poll                 |
+----------------------------+
python django mod-wsgi
share|improve this question
asked Nov 13 '10 at 13:09

Keyo
3,42563059
 	
Switching to django webserver since apache is giving me some issues. The admin page 404's and the It worked page is no longer blue. –  Keyo Nov 13 '10 at 13:25 
4 Answers
activeoldestvotes
up vote
3
down vote
accepted
Are these two lines really indented one space, as appears in your post?

 from django.contrib import admin
 admin.autodiscover()
You'll get an IndentationError if you do that. Put them flush against the left margin.

Later: Oh I see in a comment above that you found this indentation error. Marking my answer as community wiki.

share|improve this answer
answered Nov 13 '10 at 23:12

community wiki
hughdbrown
 	
Well spotted. By the way what is the general consensus on indentation, do I tab or use spaces? Tabs seems easier. –  Keyo Nov 14 '10 at 7:20
1	  	
@Keyo: The general consensus is to use four spaces. I prefer tabs, too: you can get your editor to display a tab as however many spaces you want. People say, "But what if you mix leading tabs and spaces!?!?!??! No tabs!!!" Anyway, if I ran the world, we'd all use tabs. YMMV. –  hughdbrown Nov 15 '10 at 15:31


你可能感兴趣的:(Django urls problem:It works! ... You're seeing this message because you have DEBUG = True in your D)