我最近搬到了另一台机器上,不得不再次从subversion中判断我的项目,但我非常确定这台计算机的Django 1.8版本,该项目的预期版本为1.7版本.

我试图用代码同步我的数据库以创建必要的表,但我得到了以下错误.

C:\Users\jont\Documents\ATP\Webapp>manage.py syncdb
C:\Python27\lib\site-packages\admin_tools\utils.py:9: RemovedInDjango19Warning:      
django.utils.importlib will be removed in Django 1.9.
from django.utils.importlib import import_module

c:\users\jont\documents\django-trunk\django\contrib\contenttypes\models.py:148:  
RemovedInDjango19Warning: Model class django.contrib.contenttypes.models.ContentType doesn't de
her isn't in an application in INSTALLED_APPS or else was imported before its application was  
loaded. This will no longer be supported in Django 1.9.
class ContentType(models.Model):

C:\Python27\lib\site-packages\admin_tools\dashboard\modules.py:8: RemovedInDjango19Warning: The 
django.forms.util module has been renamed. Use django.forms.utils instead.
from django.forms.util import flatatt

C:\Python27\lib\site-packages\django_tables2\tables.py:171: RemovedInDjango19Warning: SortedDict
is deprecated and will be removed in Django 1.9. attrs["base_columns"] =  
SortedDict(parent_columns)

C:\Python27\lib\site-packages\django_tables2\tables.py:193: RemovedInDjango19Warning: SortedDict 
is deprecated and will be removed in Django 1.9.
attrs["base_columns"].update(SortedDict(cols))

Traceback (most recent call last):
File "C:\Users\jont\Documents\ATP\Webapp\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "c:\users\jont\documents\django-trunk\django\core\management\__init__.py", line 336, in
execute_from_command_line
utility.execute()
File "c:\users\jont\documents\django-trunk\django\core\management\__init__.py", line 310, in 
execute
django.setup()
File "c:\users\jont\documents\django-trunk\django\__init__.py", line 23, in setup
apps.populate(settings.INSTALLED_APPS)
File "c:\users\jont\documents\django-trunk\django\apps\registry.py", line 115, in populate
app_config.ready()
File "c:\users\jont\documents\django-trunk\django\contrib\admin\apps.py", line 22, in ready
self.module.autodiscover()
File "c:\users\jont\documents\django-trunk\django\contrib\admin\__init__.py", line 24, in  
autodiscover
autodiscover_modules('admin', register_to=site)
File "c:\users\jont\documents\django-trunk\django\utils\module_loading.py", line 73, in 
autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Users\jont\Documents\ATP\Webapp\jobs\admin.py", line 4, in <module>
from jobs.views import registration
File "C:\Users\jont\Documents\ATP\Webapp\jobs\views.py", line 12, in <module>
from jobs.forms import ApplicantForm, JobForm, \
File "C:\Users\jont\Documents\ATP\Webapp\jobs\forms.py", line 8, in <module>
class JobForm(forms.ModelForm):
File "c:\users\jont\documents\django-trunk\django\forms\models.py", line 272, in __new__
"needs updating." % name
django.core.exceptions.ImproperlyConfigured: Creating a ModelForm without either the 'fields'   attribute or the 'exclude' attribute is prohibited; form JobForm needs updating.

django.core.exceptions.ImproperlyConfigured: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form JobForm needs updating.

推荐答案

就像错误提到的那样,您需要指定字段或排除字段.

试试这个

class JobForm(models.ModelForm):
    #fields

    class Meta:
        model = Job
        fields = "__all__" 

包括所有的字段

以下是相关的documentation (release notes 1.6)

以前,如果希望ModelForm使用模型上的所有字段,

如果将字段添加到模型中,这可能会导致安全问题

因此,不推荐使用此行为,并使用

如果这种安全问题真的不适用于您的情况,那么

Python-3.x相关问答推荐

根据其他数据框架的列顺序从数据框架中进行 Select

CONNEXION.EXCEPTIONS.ResolverError:运行pyz文件时未命名模块

如何转换Pandas中的数据,以使我 Select 的列名变为行值并增加行?

按小时和日期对Pandas 数据帧进行分组

如何将python点击参数设置为与选项回调不同的参数的别名?

查找值始终为零的行 pandas

requests.exceptions.InvalidSchema:未找到连接适配器.我试图遍历一个列表

python3,将整数转换为字节:对于小整数使用 to_bytes() 有哪些替代方法?

平移数组

如何使用 Selenium 和 Python 作为线程来使用事件(Chrome-Developer-Tools)?

切片的Python复杂性与元组的星号相结合

为什么 Multiprocessing 的 Lock 不会阻止其他进程使用对象?

使用一周的特定第一天将每日日期转换为每周

从 yahoo Finance python 一次下载多只股票

Python:pprint的模块错误,打印没有错误

django.core.exceptions.ImproperlyConfigured

使用 Sublime Text 3 在 Python 3 中打印 UTF-8

用于 unicode 大写单词的 Python 正则表达式

matplotlib - 模块sip没有属性setapi

如何在 Pandas 中的超 Big Data 框上创建数据透视表