为什么这个常见功能会失败?

时间:2012-05-21 16:30:02

标签: django

目前,我正在尝试对这部分代码进行故障排除,这段代码正在抛出

'NoneType' object has no attribute '__name__'

错误,整个我的应用程序。

代码部分我将其缩小为:

def get_internal_type(self):
    return CharField.__name__

Django输出错误:

AttributeError at /joinerysoft/contacts/edit-contact/details/E0452488-1756-11E1-A97B-7071BC08AB6F/84AE3FC8-40F1-11E1-B520-7071BC08AB6F/
'NoneType' object has no attribute '__name__'
Request Method: POST
Request URL:    http://127.0.0.1:8002/joinerysoft/contacts/edit-contact/details/E0452488-1756-11E1-A97B-7071BC08AB6F/84AE3FC8-40F1-11E1-B520-7071BC08AB6F/
Django Version: 1.2.7
Exception Type: AttributeError
Exception Value:    
'NoneType' object has no attribute '__name__'
Exception Location: C:\Joinerysoft\Development\joinerysoft-directory\jmsdirectory\..\jmsdirectory\generic\models.py in get_internal_type, line 41
Python Executable:  c:\python27\python.exe
Python Version: 2.7.2
Python Path:    ['C:\\Joinerysoft\\Development\\joinerysoft-directory\\jmsdirectory', 'c:\\python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg', 'c:\\python27\\lib\\site-packages\\virtualenv-1.7.1.2-py2.7.egg', 'C:\\Windows\\system32\\python27.zip', 'c:\\python27\\DLLs', 'c:\\python27\\lib', 'c:\\python27\\lib\\plat-win', 'c:\\python27\\lib\\lib-tk', 'c:\\python27', 'c:\\python27\\lib\\site-packages', 'c:\\python27\\lib\\site-packages\\PIL']
Server time:    Mon, 21 May 2012 17:11:16 +0100

来自manage.py的回溯:

C:\Joinerysoft\Development\joinerysoft-directory\jmsdirectory>c:\python27\python.exe manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "c:\python27\lib\site-packages\django\core\management\__init__.py", line 438, in execute_manager
    utility.execute()
  File "c:\python27\lib\site-packages\django\core\management\__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\python27\lib\site-packages\django\core\management\base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "c:\python27\lib\site-packages\django\core\management\base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "c:\python27\lib\site-packages\django\core\management\base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "c:\python27\lib\site-packages\django\core\management\commands\syncdb.py", line 88, in handle_noargs
    sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
  File "c:\python27\lib\site-packages\django\db\backends\creation.py", line 45, in sql_create_model
    col_type = f.db_type(connection=self.connection)
  File "c:\python27\lib\site-packages\django\db\models\fields\subclassing.py", line 28, in inner
    return func(*args, **kwargs)
  File "c:\python27\lib\site-packages\django\db\models\fields\subclassing.py", line 28, in inner
    return func(*args, **kwargs)
  File "c:\python27\lib\site-packages\django\db\models\fields\subclassing.py", line 28, in inner
    return func(*args, **kwargs)
  File "c:\python27\lib\site-packages\django\db\models\fields\__init__.py", line 220, in db_type
    return connection.creation.data_types[self.get_internal_type()] % data
  File "C:\Joinerysoft\Development\joinerysoft-directory\jmsdirectory\..\jmsdirectory\generic\models.py", line 40, in get_internal_type
    return CharField.__name__
AttributeError: 'NoneType' object has no attribute '__name__'

0 个答案:

没有答案