在Django管理页面中,我试图使用import_export库导入学生表,但它提供了
在/ admin / catalog / student / import /的TypeError不是'NoneType'对象 可调用的请求方法:POST请求URL:
http://127.0.0.1:8000/admin/catalog/student/import/ Django版本: 2.2.2异常类型:TypeError异常值:'NoneType'对象不可调用异常位置: C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages \ import_export \ admin.py 在write_to_tmp_storage中,第229行Python可执行文件: C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ Scripts \ python.exe Python版本:3.7.3 Python路径:
['C:\ Users \ sdixit23.EAD \ django_projects \ django_projects \ glacier', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ Scripts \ python37.zip', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ DLLs', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ Scripts', 'c:\ users \ sdixit23.ead \ appdata \ local \ programs \ python \ python37-32 \ Lib', 'c:\ users \ sdixit23.ead \ appdata \ local \ programs \ python \ python37-32 \ DLLs', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages \ odf', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages \ odf', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages \ odf', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages \ odf', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages \ odf', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages \ odf', 'C:\ Users \ sdixit23.EAD \ Envs \ my_django_environment \ lib \ site-packages \ odf'] 服务器时间:2019年8月28日星期三17:31:27 +0100
我尝试检查models.py和admin.py文件。我什至尝试重新创建该站点,但是我不知道为什么它不起作用。 实际上,它不适用于我的任何模型。
class StudentAdmin(ImportExportModelAdmin):
list_display = ('student_ID',
'student_First_Name',
'student_Last_Name',
'student_DOB',
'gender',
'student_Gmail',
'parent_Name',
'parent_Email',
'contact_Number',
'city',
'country',
'comments',
)
# Register the admin class with the associated model
admin.site.register(Student, StudentAdmin)
class Student(models.Model):
"""Model representing a Student."""
student_ID = models.CharField(primary_key=True, max_length=10, help_text='Enter Student ID as PYNNN')
student_First_Name = models.CharField(max_length=100, help_text='Enter Student First Name')
student_Last_Name = models.CharField(max_length=100, help_text='Enter Student First Name')
student_DOB = models.DateField(help_text='Enter Date of Birth as YYYY-MM-DD', null=True)
gender = models.CharField(
max_length=10,
choices=STUDENT_GENDER,
blank=True,
default='',
help_text='Enter Student Gender',
)
student_Gmail = models.EmailField(max_length=100, help_text='Enter student Gmail-id. Its Mandatory to use Gmail-id', null=True)
parent_Name = models.CharField(max_length=100, help_text='Enter Parent Full Name', null=True)
parent_Email = models.EmailField(max_length=100, help_text='Enter Parent Email', null=True)
contact_Number = models.CharField(max_length=11, help_text='Enter Mobile Number (e.g. 07910100045)', null=True)
city = models.CharField(max_length=50, help_text='Enter City Name', null=True)
country = CountryField(null=True, default= "United Kingdom")
comments = models.TextField(max_length=200, help_text='Any Specific comments', null=True)
def get_absolute_url(self):
"""Returns the url to access a particular student instance."""
return reverse('student-detail', args=[str(self.pk)])
def __str__(self):
"""String for representing the Model object."""
return f'{self.student_First_Name} {self.student_Last_Name}'
预期结果是“预览页面”,相反,我看到此错误
TypeError at /admin/catalog/student/import/
'NoneType' object is not callable
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/catalog/student/import/
Django Version: 2.2.2
Exception Type: TypeError
Exception Value: 'NoneType' object is not callable
Exception Location: C:\Users\sdixit23.EAD\Envs\my_django_environment\lib\site-packages\import_export\admin.py in write_to_tmp_storage, line 229
Python Executable: C:\Users\sdixit23.EAD\Envs\my_django_environment\Scripts\python.exe
Python Version: 3.7.3
Python Path: ['C:\\Users\\sdixit23.EAD\\django_projects\\django_projects\\glacier',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\Scripts\\python37.zip',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\DLLs',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\Scripts',
'c:\\users\\sdixit23.ead\\appdata\\local\\programs\\python\\python37-32\\Lib',
'c:\\users\\sdixit23.ead\\appdata\\local\\programs\\python\\python37-32\\DLLs',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib\\site-packages',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib\\site-packages\\odf',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib\\site-packages\\odf',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib\\site-packages\\odf',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib\\site-packages\\odf',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib\\site-packages\\odf',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib\\site-packages\\odf',
'C:\\Users\\sdixit23.EAD\\Envs\\my_django_environment\\lib\\site-packages\\odf']
Server time: Wed, 28 Aug 2019 17:31:27 +0100