diff --git a/src/django/rendering.js b/src/django/rendering.js
index fbb286e..856b4d9 100644
--- a/src/django/rendering.js
+++ b/src/django/rendering.js
@@ -644,9 +644,9 @@ CHANNEL_LAYERS = {
htmx_body += `
Add A ${model.name}
-
+
${model.name} List
-
`
})
@@ -1060,6 +1060,8 @@ CHANNEL_LAYERS = {
var imports = 'from django.db import models\n'
imports += 'from django.urls import reverse\n'
+ const parentImportClasses = new Set();
+
let importGIS = false;
let importPostgres = false;
@@ -1074,7 +1076,8 @@ CHANNEL_LAYERS = {
const model = this.store.getters.modelData(parent.model)
return model.name
} else if (parent.type == 'django') {
- return parent.class.split(".").pop()
+ parentImportClasses.add(parent.class);
+ return parent.class.split(".").pop();
}
}))
@@ -1163,6 +1166,12 @@ CHANNEL_LAYERS = {
}
})
+
+ parentImportClasses.forEach((parent) => {
+ const parentSplit = parent.split(".");
+ const parentModule = parentSplit.pop();
+ imports += 'from ' + parentSplit.join('.') + " import " + parentModule + "\n";
+ })
if (importGIS) {
imports += 'from django.contrib.gis.db import models as gis_models\n'