没有模块命名博客 [英] No module named blog
本文介绍了没有模块命名博客的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误是
错误:没有名为blog的模块
这是我的 settings.py
INSTALLED_APPS =(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'mysite.blog',
#取消注释下一行以启用管理员:
#'django.contrib.admin',
#取消注释下一行以启用管理员文档:
#'django.contrib.admindocs',
)
DATABASES = {
'defau lt;:{
'ENGINE':'django.db.backends.sqlite3',#添加'postgresql_psycopg2','mysql','sqlite3'或'oracle'。
'NAME':'/var/db/django.db',#或使用sqlite3的数据库文件路径。
'USER':'',#不与sqlite3一起使用。
'PASSWORD':'',#不与sqlite3一起使用。
'HOST':'',#设置为localhost的空字符串。不适用于sqlite3。
'PORT':'',#设置为空字符串为默认值。不适用于sqlite3。
}
}
这里是所有的 model.py
$ d code从django.db导入模型
class BlogPost(models .Model):
title = models.CharField(max_length = 150)
body = models.TextField()
timestamp = models.DataTimeField()
我在stackoverflow中搜索过类似的问题,但这些解决方案对我来说无效。
解决方案
仅尝试博客:
INSTALLED_APPS =(
.......
'blog',
......
)
I'm a newbie in django.Now I'm following a book named Python Web Development with Django and creating a light blog.With the app blog and sqlite3 chosen for testing, an error came up when running ./manage.py syncdb.
The error is that
Error: No module named blog
This is part of my settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'mysite.blog',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/var/db/django.db', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
Here is all of the model.py in blog app:
from django.db import models
class BlogPost(models.Model):
title = models.CharField(max_length = 150)
body = models.TextField()
timestamp = models.DataTimeField()
I've searched through the similar questions in stackoverflow, but those resolutions doesn't work for me.
解决方案
Try blog only:
INSTALLED_APPS = (
.......
'blog',
......
)
这篇关于没有模块命名博客的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文