% settings.py %

MIDDLEWARE_CLASSES = (
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'mysite.books',
    'django.contrib.admin',
)



% urls.py %

from django.conf.urls.defaults import *
from django.contrib import admin
from mysite.views import current_datetime, hours_ahead

admin.autodiscover()

urlpatterns = patterns('',
        (r'^time/$', current_datetime),
        (r'^time/plus/(\d{1,2})/$', hours_ahead),
        (r'^admin/(.*)', admin.site.root),
)



% models.py %

from django.db import models

class Publisher(models.Model):
        name = models.CharField(max_length=30)
        address = models.CharField(max_length=50)
        city = models.CharField(max_length=60)
        state_province = models.CharField(max_length=30)
        country = models.CharField(max_length=50)
        website = models.URLField()
        def __str__(self):
                return self.name


class Author(models.Model):
        salutation = models.CharField(max_length=10)
        first_name = models.CharField(max_length=30)
        last_name = models.CharField(max_length=40)
        email = models.EmailField()
        headshot = models.ImageField(upload_to='/tmp')
        def __str__(self):
                return '%s %s' % (self.first_name, self.last_name)

class Book(models.Model):
        title = models.CharField(max_length=100)
        authors = models.ManyToManyField(Author)
        publisher = models.ForeignKey(Publisher)
        publication_date = models.DateField()
        num_pages = models.IntegerField(blank=True, null=True)

        def __str__(self):
                return self.title



% admin.py (currently in my app folder (\books) %

from django.contrib import admin
from mysite.books.models import Book

admin.site.register(Book)
----------------------------------------------------------------------------

==> above are my settings. App name is books. I'm curious about where
to put admin.py file.
(Maybe in my app folder (\books)? That's what I'm doing right now.)



I was at first following my Django book's instruction to create
administration interface and soon realized that the method on the book
was not applicable to Django 1.0.

I'm not interested in several options I can override. Just wanting to
test default interface but It just doesn't work!

with these settings, I encounter this error

--------------------------------------------------------------
File "F:\Python26\Lib\site-packages\django\core\servers\basehttp.py",
line 278, in run
    self.result = application(self.environ, self.start_response)

  File "F:\Python26\Lib\site-packages\django\core\servers
\basehttp.py", line 635, in __call__
    return self.application(environ, start_response)

  File "F:\Python26\Lib\site-packages\django\core\handlers\wsgi.py",
line 243, in __call__
    response = middleware_method(request, response)

  File "F:\Python26\Lib\site-packages\django\contrib\sessions
\middleware.py", line 35, in process_response
    request.session.save()

  File "F:\Python26\Lib\site-packages\django\contrib\sessions\backends
\db.py", line 52, in save
    session_key = self.session_key,

  File "F:\Python26\Lib\site-packages\django\contrib\sessions\backends
\base.py", line 152, in _get_session_key
    self._session_key = self._get_new_session_key()

  File "F:\Python26\Lib\site-packages\django\contrib\sessions\backends
\base.py", line 144, in _get_new_session_key
    if not self.exists(session_key):

  File "F:\Python26\Lib\site-packages\django\contrib\sessions\backends
\db.py", line 25, in exists
    Session.objects.get(session_key=session_key)

  File "F:\Python26\Lib\site-packages\django\db\models\manager.py",
line 93, in get
    return self.get_query_set().get(*args, **kwargs)

  File "F:\Python26\Lib\site-packages\django\db\models\query.py", line
304, in get
    num = len(clone)

  File "F:\Python26\Lib\site-packages\django\db\models\query.py", line
160, in __len__
    self._result_cache = list(self.iterator())

  File "F:\Python26\Lib\site-packages\django\db\models\query.py", line
275, in iterator
    for row in self.query.results_iter():

  File "F:\Python26\Lib\site-packages\django\db\models\sql\query.py",
line 206, in results_iter
    for rows in self.execute_sql(MULTI):

  File "F:\Python26\Lib\site-packages\django\db\models\sql\query.py",
line 1724, in execute_sql
    cursor.execute(sql, params)

  File "F:\Python26\Lib\site-packages\django\db\backends\util.py",
line 19, in execute
    return self.cursor.execute(sql, params)

ProgrammingError: error:  There's no relation named "django_session"
<--- message translated by my own because I'm not English user. Just
focus on the meanig of this message cause this might be not identical.
_____________________________________________

I'm guessing this message is related with my db table. Can't solve
error though. Or might be serious error somewhere. Stuck on this
problem half of my day and making me frustrated. Please give me help
to get out of this damned message :(



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

Reply via email to