我检查了代码 跟下载的一样,怎么解决呢?
ValueError at /userfavs/
Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x0000027597551EF0>": "UserFav.user" must be a "UserProfile" instance.
Request Method: POST
Request URL: http://127.0.0.1:8000/userfavs/
Django Version: 1.11
Exception Type: ValueError
Exception Value:
Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x0000027597551EF0>": "UserFav.user" must be a "UserProfile" instance.
Exception Location: D:\Envs\MxShop\lib\site-packages\django\db\models\fields\related_descriptors.py in __set__, line 216
Python Executable: D:\Envs\MxShop\Scripts\python.exe
Python Version: 3.6.0
Python Path:
['C:\\Users\\huang\\PycharmProjects\\MxShop\\extra_apps',
'C:\\Users\\huang\\PycharmProjects\\MxShop\\apps',
'C:\\Users\\huang\\PycharmProjects\\MxShop',
'C:\\Users\\huang\\PycharmProjects\\MxShop',
'C:\\Program Files\\JetBrains\\PyCharm 2018.2.4\\helpers\\pydev',
'C:\\Users\\huang\\PycharmProjects\\MxShop',
'C:\\Users\\huang\\PycharmProjects\\MxShop\\apps',
'C:\\Users\\huang\\PycharmProjects\\MxShop\\extra_apps',
'C:\\Program Files\\JetBrains\\PyCharm 2018.2.4\\helpers\\pydev',
'C:\\Users\\huang\\.PyCharm2018.2\\system\\cythonExtensions',
'D:\\Envs\\MxShop\\Scripts\\python36.zip',
'C:\\Users\\huang\\AppData\\Local\\Programs\\Python\\Python36\\DLLs',
'C:\\Users\\huang\\AppData\\Local\\Programs\\Python\\Python36\\lib',
'C:\\Users\\huang\\AppData\\Local\\Programs\\Python\\Python36',
'D:\\Envs\\MxShop',
'D:\\Envs\\MxShop\\lib\\site-packages',
'D:\\Envs\\MxShop\\lib\\site-packages\\setuptools-39.1.0-py3.6.egg',
'C:\\Program Files\\JetBrains\\PyCharm '
'2018.2.4\\helpers\\pycharm_matplotlib_backend']
Server time: 星期日, 5 五月 2019 15:09:54 +0800
Django REST framework课程视频,RESTFul API前后端分离开发
了解课程