Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
django管理站点覆盖change_list.html_Django - Fatal编程技术网

django管理站点覆盖change_list.html

django管理站点覆盖change_list.html,django,Django,他们是否有可能覆盖change_list.html? 我只想添加另一个表/列表视图 models.py class StudentsEnrollmentRecord(models.Model): Student_Users = models.ForeignKey(StudentProfile, related_name='students', on_delete=models.CASCADE,null=True) School_Year = models.ForeignKey(

他们是否有可能覆盖change_list.html?

我只想添加另一个表/列表视图

models.py

class StudentsEnrollmentRecord(models.Model):
    Student_Users = models.ForeignKey(StudentProfile, related_name='students', on_delete=models.CASCADE,null=True)
    School_Year = models.ForeignKey(SchoolYear, related_name='+', on_delete=models.CASCADE, null=True, blank=True)
    Courses = models.ForeignKey(Course, related_name='+', on_delete=models.CASCADE, null=True, blank=True)
    Section = models.ForeignKey(Section, related_name='+', on_delete=models.CASCADE, null=True,blank=True)
管理员

class StudentsEnrollmentRecordAdmin(admin.ModelAdmin):
    #inlines = [InLineSubject]
    list_display = ('lrn', 'Student_Users', 'Education_Levels', 'Courses', 'Section', 'Payment_Type', 'Discount_Type' ,'School_Year')
    #list_select_related = ('Student_Users')
    ordering = ('Education_Levels','Student_Users__lrn')
    list_filter = ('Student_Users','Education_Levels','Section','Payment_Type')


    def lrn(self, obj):
        return  obj.Student_Users.lrn
更新示例

您必须在项目路径中创建一个目录,如:myproject/templates/admin(如果这是您在settings.py的DIRS template options中指定的模板设置),并在此目录中创建一个名为change_list.html的新文件。Django随后将使用此选项,而不是默认选项

此外,您还可以使用这个新的change_list.html模板展开/使用


有关覆盖和替换默认管理和注册模板的更多参考信息,请参见:->搜索“覆盖管理模板”

有任何具体答案吗?我必须更改或添加我的admin.py代码吗?@justinorcullo你是什么意思?您的问题并不具体(它只是询问如何修改change_list.html,它没有说明您想要更改什么),答案正好告诉您如何进行更改。不,如果您只想更改列表,则不必修改admin.py。html添加另一个表是什么意思?换个型号?还是为同一型号?为另一型号添加另一个表格,先生,这是不可能的。django管理站点在列表视图中一次处理一个模型。先生,怎么做?你能给我举个例子吗?我举个例子先生,看看我的更新例子