Как исправить ошибку TypeError в / admin / pages / course / add / in Django admin? - PullRequest
0 голосов
/ 21 июня 2020

Я сделал свои модели в models.py и запустил миграции после makemigrations. Я также зарегистрировал свою модель на admin.py, и я вижу, что она появляется в панели администратора. Но когда я нажал add course, я получил следующую ошибку:


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

1 Ответ

0 голосов
/ 21 июня 2020

В вашей модели курса go для модели года и установите null = True, blank = True year = models.IntegerField (null = True, blank = True) Убедитесь, что у вас нет аргументов, которые вы не узнаете .

...