ブログやデータベースなどを作っています。つまり、「posts」という名前のデータベースがあります。
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'posts', # Or path to database file if using sqlite3.
'USER': '*******', # Not used with sqlite3.
'PASSWORD': '*******', # Not used with sqlite3.
'HOST': '/Applications/MAMP/tmp/mysql/mysql.sock', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '****', # Set to empty string for default. Not used with sqlite3.
}
models.py
from django.db import models
class posts(models.Model):
author = models.CharField(max_length = 30)
title = models.CharField(max_length = 100)
bodytext = models.TextField()
timestamp = models.DateTimeField()
ビュー.py
from django.shortcuts import render_to_response
from models import posts
#from settings import default
def index(request):
entries = posts.objects.all()[:10]
return render_to_response('homepage/index.html', {'posts' : entries}
出力
OperationalError at /
(1049, "Unknown database 'posts.homepage_posts'")
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.4
Exception Type: OperationalError
Exception Value:
(1049, "Unknown database 'posts.homepage_posts'")
Exception Location: /Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg/MySQLdb/connections.py in __init__, line 187
Python Executable: /usr/bin/python
Python Version: 2.7.1
Python Path:
['/Users/thor/Sites/FirstBlog',
'/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
Server time: Wed, 2 May 2012 19:56:53 -0500
データベース名に自動的にサフィックス.homepage_posts
が付けられ、アクセスできなくなります。助けてください?