在admin.py中写fieldsets
fieldsets = [
('base', {'field': ['btitle']}),
('super', {'field': ['bpub_date']}),
]
元组间没有加‘,’,导致 无法启动Django项目,报错如下:
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/python/.virtualenvs/h1/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/python/.virtualenvs/h1/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/home/python/.virtualenvs/h1/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/python/.virtualenvs/h1/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/python/.virtualenvs/h1/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/python/.virtualenvs/h1/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/python/.virtualenvs/h1/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/python/Desktop/django/test1/booktest/admin.py", line 7, in
class BookInfoAdmin(admin.ModelAdmin):
File "/home/python/Desktop/django/test1/booktest/admin.py", line 14, in BookInfoAdmin
('super', {'field': ['bpub_date']})
TypeError: 'tuple' object is not callable
分析看图:找到路径,line对应的行数根据错误去修改