summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/frest/manage/utils.py13
-rw-r--r--src/frest/templates/form.txt1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/frest/manage/utils.py b/src/frest/manage/utils.py
index 47adeb1..ed07477 100644
--- a/src/frest/manage/utils.py
+++ b/src/frest/manage/utils.py
@@ -148,6 +148,15 @@ def create_model_cli(name):
f.write(modeltext)
+def create_forms(name):
+ with open("templates/form.txt") as f:
+ formstext = "".join(f.readlines())
+
+ formstext = formstext.replace("%%NAME%%", name.capitalize())
+ with open(f"scheme/{name}/forms.py", "w") as f:
+ f.write(formstext)
+
+
def create_app(name):
name = name.lower().replace("-", "_")
@@ -174,3 +183,7 @@ def create_app(name):
logging_arg("Create model for {}...\n", name)
create_model_cli(name)
logging("OK", 3, "\n")
+
+ logging_arg("Create {}... ", f"scheme/{name}/forms.py")
+ create_forms(name)
+ logging("OK", 3, "\n")
diff --git a/src/frest/templates/form.txt b/src/frest/templates/form.txt
index f4b2c14..ed1017e 100644
--- a/src/frest/templates/form.txt
+++ b/src/frest/templates/form.txt
@@ -8,3 +8,4 @@ class %%NAME%%Form(ModelForm):
def __init__(self, data):
super().__init__(self.model)
self.data = data
+ self.ignore = []