是否可以强制django_sql_explorer扩展我的base.html?

时间:2016-07-15 15:30:00

标签: django

我已经用pip安装了django_sql_explorer包。 我想知道是否有可能使\ django_sql_explorer扩展我的base.html而没有项目中的所有django_sql_explorer源代码?

1 个答案:

答案 0 :(得分:1)

如果你看一下这里:https://github.com/groveco/django-sql-explorer/blob/master/explorer/templates/explorer/base.html你会看到django-sql-explorer定义了一个from PyQt5 import QtCore, QtWidgets from PyQt5.QtCore import pyqtSlot from imp_sourceform import Ui_SourceForm from imp_destform import Ui_DestinationForm class WController(QtWidgets.QMainWindow): def __init__(self, parent=None): super(WController, self).__init__(parent) self.central_widget = QtWidgets.QStackedWidget() self.setCentralWidget(self.central_widget) self.sourcewindow = SourceForm() self.destinationwindow = DestinationForm() self.central_widget.addWidget(self.sourcewindow) self.central_widget.addWidget(self.destinationwindow) self.central_widget.setCurrentWidget(self.sourcewindow) self.sourcewindow.selectdestinationsbutton.clicked.connect(lambda: self.navigation_control(1)) self.destinationwindow.backbutton.clicked.connect(lambda: self.navigation_control(0)) def navigation_control(self, topage): if topage == 1: self.central_widget.setCurrentWidget(self.destinationwindow) elif topage == 0: self.central_widget.setCurrentWidget(self.sourcewindow) class SourceForm(QtWidgets.QWidget, Ui_SourceForm): def __init__(self): super(SourceForm, self).__init__() self.setupUi(self) self.treeWidget.itemChanged.connect(self.handle_treewidget_itemchange) @pyqtSlot() def handle_treewidget_itemchange(self,row,col): if row.parent() is None and row.checkState(col) == QtCore.Qt.Unchecked: for x in range(0,row.childCount()): row.child(x).setCheckState(0, QtCore.Qt.Unchecked) elif row.parent() is None and row.checkState(col) == QtCore.Qt.Checked: for x in range(0,row.childCount()): row.child(x).setCheckState(0, QtCore.Qt.Checked) else: pass class DestinationForm(QtWidgets.QWidget, Ui_DestinationForm): def __init__(self): super(DestinationForm, self).__init__() self.setupUi(self) if __name__ == '__main__': import sys app = QtWidgets.QApplication(sys.argv) window = WController() window.show() sys.exit(app.exec_()) ,其他模板会覆盖它。因此,如果您想使用自己的explorer/base.html在其中一个应用程序中创建一个名为base.html的目录,并在其中添加templates/explorer(这将覆盖django-sql-explorer' s)。

请注意,此base.html不能与您自己的网站base.html相同,因为您需要尊重django-sql-explorer实际上的块名称定义以便内容可见。