I have a template that renders a series of text boxes for user input, which will be saved in a database to render a final document:
It is created by a nested loop, the outer defines the number of rows and the inner creates the container with the text boxes and associated graphics.
Would someone point me to documentation that has examples of including code in Model Forms as the tutorials didn’t help me learn how to do that; at least not how I could understand it.
Alternatively, is there a way to clean the data created with tag and supplied via Post?
Template:
{% load static %}
<!DOCTYPE html>
<html lang = "en">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
<title>Strategy Map</title>
</head>
<form action = "{% url "survey" %}" method = "POST">
{% csrf_token %}
<body>
<h1>Strategy Map</h1>
{% for n in numrows %}
<!--Create flexbox to render header graphic-->
<div class="container" style="top: 5%;">
<!--Create LOO shape-->
<div class="item_LoO_Name">
<h1>Test</h1>
</div>
<!--Create row of topic shapes and spacer between shapes-->
<!--Create pointed arrow and space to Outcome-->
{% for x in numobj %}
<div class="space"></div>
<textarea id='ObjectiveTextArea' name={{ x|add:n }}></textarea>
{% endfor %}
<div class="space"></div>
<div class="triangle-right"></div>
<div class="spaceblank"></div>
<!--Create Outcome Shape-->
<div class="item_Outcome_Name">
<h1>Test</h1>
</div>
</div>
{% endfor %}
<div>
<button onclick="location.href='{% url 'survey' %}'"><lable>Next Survey</lable></button>
</div>
</body>
</html>
</form>
the model is:
class Objective_Text(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
objective_text = models.CharField(max_length=1000, blank = True)
objective_num = models.CharField(max_length=10, blank = True)
timestamp= models.TimeField(auto_now = True)
def __str__(self):
return f"User: {self.user} Objective: {self.objective_num} Text: {self.objective_text} at {self.timestamp}"