Python 如何修复Django admin中/admin/pages/course/add/in的TypeError?
我在Python 如何修复Django admin中/admin/pages/course/add/in的TypeError?,python,django,django-models,django-admin,Python,Django,Django Models,Django Admin,我在models.py中完成了我的模型,并在makemigrations之后运行迁移。我还将我的模型注册到了admin.py,我可以看到它出现在管理面板中。但是,当我单击“添加课程”时,它给了我以下错误: TypeError at /admin/pages/course/add/ function missing required argument 'year' (pos 1) Request Method: GET Request URL: http://127.0.0.1:8000/
models.py中完成了我的模型,并在makemigrations
之后运行迁移。我还将我的模型注册到了admin.py
,我可以看到它出现在管理面板中。但是,当我单击“添加课程”时,它给了我以下错误:
TypeError at /admin/pages/course/add/
function missing required argument 'year' (pos 1)
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/pages/course/add/
Django Version: 3.0.7
Exception Type: TypeError
Exception Value:
function missing required argument 'year' (pos 1)
Exception Location: C:\Users\ahnaa\OneDrive\Documents\Web Developent\Django\school_app\venv\lib\site-packages\django\db\models\fields\__init__.py in get_default, line 829
Python Executable: C:\Users\ahnaa\OneDrive\Documents\Web Developent\Django\school_app\venv\Scripts\python.exe
Python Version: 3.8.3
Python Path:
['C:\\Users\\ahnaa\\OneDrive\\Documents\\Web Developent\\Django\\school_app',
'C:\\Users\\ahnaa\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip',
'C:\\Users\\ahnaa\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs',
'C:\\Users\\ahnaa\\AppData\\Local\\Programs\\Python\\Python38-32\\lib',
'C:\\Users\\ahnaa\\AppData\\Local\\Programs\\Python\\Python38-32',
'C:\\Users\\ahnaa\\OneDrive\\Documents\\Web '
'Developent\\Django\\school_app\\venv',
'C:\\Users\\ahnaa\\OneDrive\\Documents\\Web '
'Developent\\Django\\school_app\\venv\\lib\\site-packages']
Server time: Sun, 21 Jun 2020 19:50:52 +0600
在您的课程模型中,转到年份模型并设置null=True,blank=True
年份=型号.IntegerField(null=True,blank=True)
确保没有您无法识别的参数。在您的课程模型中,转到年份模型并设置null=True,blank=True
年份=型号.IntegerField(null=True,blank=True)
确保没有您无法识别的参数。您可以发布您的模型吗