I have ceated several django apps and stuffs for my own fun and so far everything has been working fine.
Now I just created new project (django 1.2.1) and have run into trouble from 1st moments.
I created new app - game and new model Game. I created admin.py and put related stuff into it. Ran syncdb and went to check into admin. Model did not show up there.
I proceeded to check and doublecheck and read through previous similar threads: Registered models do not show up in admin Django App Not Showing up in Admin Interface
But as far as I can tell, they don't help me either. Perhaps someone else can point this out for me.
models.py in game app:
# -*- coding: utf-8 -*-
from django.db import models
class Game(models.Model):
type = models.IntegerField(blank=False, null=False, default=1)
teamone = models.CharField(max_length=100, blank=False, null=False)
teamtwo = models.CharField(max_length=100, blank=False, null=False)
gametime = models.DateTimeField(blank=False, null=False)
admin.py in game app:
# -*- coding: utf-8 -*-
from jalka.game.models import Game
from django.contrib import admin
class GameAdmin(admin.ModelAdmin):
list_display = ['type', 'teamone', 'teamtwo', 'gametime']
admin.site.register(Game, GameAdmin)
project settings.py:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'jalka.urls'
TEMPLATE_DIRS = (
"/home/projects/jalka/templates/"
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'game',
)
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'^jalka/', include('jalka.foo.urls')),
(r'^admin/', include(admin.site.urls)),
)
Hmmmm...Try change include of your app in settings.py:
From:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'game',
....
To:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'YOUR_PROJECT.game',# OR 'YOUR_PROJECT.Game'