报错 must be a foreign key or a many-to-many field.
来源:7-2 drf的token登录和原理-1
大地主4381166
2019-07-18
makemigrations的时候爆这个错
ERRORS:
<class 'rest_framework.authtoken.admin.TokenAdmin'>: (admin.E038) The value of 'autocomplete_fields[0]' must be a foreign key or a many-to-many field.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users.apps.UsersConfig',
'goods.apps.GoodsConfig',
'trade.apps.TradeConfig',
'user_operation.apps.UserOperationConfig',
'crispy_forms',
'xadmin',
'DjangoUeditor',
'django_filters',
'rest_framework',
'corsheaders',
'rest_framework.authtoken'
]
class TokenAdmin(admin.ModelAdmin):
list_display = ('key', 'user', 'created')
fields = ('user',)
ordering = ('-created',)
autocomplete_fields = ('user',)
2回答
-
bobby
2019-07-21
00 -
大地主4381166
提问者
2019-07-18
-jango 2.1
asn1crypto 0.24.0
attrs 18.2.0
Automat 0.7.0
backports.csv 1.0.7
baidu-aip 2.2.13.0
certifi 2019.3.9
cffi 1.11.5
chardet 3.0.4
constantly 15.1.0
coreapi 2.3.3
coreschema 0.0.4
cryptography 2.4.2
cssselect 1.0.3
decorator 4.4.0
defusedxml 0.6.0
diff-match-patch 20181111
Django 2.0
django-crispy-forms 1.6.0
django-filter 2.1.0
django-formtools 2.1
django-guardian 2.0.0
django-import-export 1.2.0
django-reversion 2.0.0
djangorestframework 3.10.0
EasyProcess 0.2.5
et-xmlfile 1.0.1
Faker 1.0.4
future 0.15.2
httplib2 0.9.2
hyperlink 18.0.0
idna 2.8
incremental 17.5.0
itypes 1.1.0
jdcal 1.4.1
Jinja2 2.10.1
lxml 4.3.0
Markdown 3.1.1
MarkupSafe 1.1.1
mysqlclient 1.4.2.post1
odfpy 1.4.0
openpyxl 2.6.2
parsel 1.5.1
Pillow 5.4.1
pip 19.1.1
py 1.8.0
pyasn1 0.4.5
pyasn1-modules 0.2.3
pycparser 2.19
PyDispatcher 2.0.5
PyHamcrest 1.9.0
PyMySQL 0.9.3
pyOpenSSL 18.0.0
python-dateutil 2.8.0
pytz 2019.1
PyYAML 5.1.1
requests 2.21.0
setuptools 41.0.1
six 1.10.0
sqlparse 0.3.0
tablib 0.13.0
text-unidecode 1.2
Twisted 18.9.0
uritemplate 3.0.0
urllib3 1.24.1
w3lib 1.20.0
wheel 0.33.4
xlrd 1.2.0
XlsxWriter 1.1.8
xlwt 1.3.0
zope.interface 4.6.0
00
Python前后端分离开发Vue+Django REST framework实战
2873 学习 · 2461 问题
相似问题