Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin page not showing

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:

What I get trying to access the admin page

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                 |
+----------------------------+
like image 244
Keyo Avatar asked Nov 13 '10 13:11

Keyo


People also ask

How do I enable the Django admin app?

Then navigate to the admin panel’s URL in a browser of your choice. Be sure to input your server’s IP address. You will receive a login screen similar to this. Getting to this screen lets us know that we have successfully enabled the admin app. Though we have enabled the app, we may not have set up a Django administration account yet.

What is the default title of an admin page in Django?

By default, this is “Django administration”. The text to put at the end of each admin page’s <title> (a string). By default, this is “Django site admin”. The URL for the “View site” link at the top of each admin page.

How do I connect posts and comments in Django?

To connect the two together, we need to register our Posts and Comments models inside of the admin file of blogsite. Then, open the admin.py file in a text editor of your choice. The file will be populated with an import statement and a comment. from django.contrib import admin # Register your models here.

What is the best way to manage content in Django?

One of the most powerful parts of Django is the automatic admin interface. It reads metadata from your models to provide a quick, model-centric interface where trusted users can manage content on your site. The admin’s recommended use is limited to an organization’s internal management tool.


2 Answers

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.

like image 126
hughdbrown Avatar answered Oct 17 '22 13:10

hughdbrown


If you're doing this via Apache and mod_wsgi, then you're not following the tutorial. The tutorial tells you to use the development server, for a good reason: with Apache, you need to restart it whenever you make a code change. The dev server detects changes and restarts itself for you.

like image 41
Daniel Roseman Avatar answered Oct 17 '22 14:10

Daniel Roseman