1.No module named“MySQLdb”
2.NoReverseMatch at/
’url’requires a non-empty first argument.The syntax changed in Django1.5.See the docs
解决办法:路径:diango1.5版本路径需要加引号。即可解决上述问题。
例如:{% url“new_index”%}。
3.DjangoUnicodeDecodeError at/
解决办法:项目路径出现中文的问题。
4.NoReverseMatch at/
Reverse for’news_index’with arguments‘()’and keyword arguments‘{}’not found
解决办法:这种问题是没有正确的设置路径导致。这个可以先检查settings里的路径然后再检查其他子的app的路径。
5.OperationalError at/
(2003,‘Can’t connect to MySQL server on‘localhost’(10061)’)
解决办法:这个问题是因为mysql数据库没有打开。
6.TypeError at/news/
Unsupported opeaand type(s) for-:’unicode’ and ‘int’
解决办法:加了一个类型转换把unicode转换成int ;
例如:int(u’2’)。
7.ImportError: cannot import name Role
解决办法:from Manager.Role.models import Role在引用的地方查看路径是否正确。
8.NameError: name 'true' is not defined
Unhandled exception in thread started by >
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 92, in inner_run
self.validate(display_num_errors=True)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 280, in validate
num_errors = get_validation_errors(s, app)
File "C:\Python27\lib\site-packages\django\core\management\validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 166, in get_app_errors
self._populate()
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 72, in _populate
self.load_app(app_name, True)
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
__import__(name)
File "F:\workplacepython\HBS_Photographer\Manager\News\models.py", line 10, in
class News(models.Model):
File "F:\workplacepython\HBS_Photographer\Manager\News\models.py", line 14, in News
AddTime=models.DateTimeField(u'添加时间',auto_now_add=true)
NameError: name 'true' is not defined
解决办法:AddTime=models.DateTimeField(u'添加时间',auto_now_add=True)原因是小写的true改成大写字母True就可以了。
9.CommandError: One or more models did not validate:
CommandError: One or more models did not validate:
Photo.photo: 'FileFormat_ID' has a relation with model 图片格式id, which has either not been installed or is abstract.
Photo.photo: 'PhotoGrapherID' has a relation with model , which has either not been installed or is abstract.
Other.collect: 'Photo_ID' has a relation with model 图片ID, which has either not been installed or is abstract.
解决办法:
Q1.Photo.photo: 'FileFormat_ID' has a relation with model 图片格式id, which has either not been installed or is abstract。
A1:把FileFormat_ID=models.ForeignKey(u’文件格式ID’,FileFormat)改成FileFormat_ID=models.ForeignKey(FileFormat)。
Q2:Photo.photo: 'PhotoGrapherID' has a relation with model , which has either not been installed or is abstract.
A1:在settings里加'Manager.Photographer'。
Q3:Other.collect: 'Photo_ID' has a relation with model 图片ID, which has either not been installed or is abstract.
A3:Photo_ID=models.ForeignKey(u’图片ID’,Photo)改成Photo_ID=models.ForeignKey(Photo)