Skip to content

Instantly share code, notes, and snippets.

@jaradc
Created February 16, 2020 17:57
Show Gist options
  • Save jaradc/9a98261135c938a9ae55f08075c18bde to your computer and use it in GitHub Desktop.
Save jaradc/9a98261135c938a9ae55f08075c18bde to your computer and use it in GitHub Desktop.
An example of what the output looks like for inlineformset_factory with 3 filled-out module forms containing Title, Description and 2 extra forms in the formset.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="" method="post">
<input type="hidden" name="csrfmiddlewaretoken"
value="8KkIr5XSv5SdWGKBaEVsQHqvpuVxJehTyeLHgP7p5ciIEp8N6cFghxSSh02msbOC">
<input type="hidden" name="modules-TOTAL_FORMS" value="5" id="id_modules-TOTAL_FORMS">
<input type="hidden" name="modules-INITIAL_FORMS" value="3" id="id_modules-INITIAL_FORMS">
<input type="hidden" name="modules-MIN_NUM_FORMS" value="0" id="id_modules-MIN_NUM_FORMS">
<input type="hidden" name="modules-MAX_NUM_FORMS" value="1000" id="id_modules-MAX_NUM_FORMS">
<p>
<label for="id_modules-0-title">Title:</label>
<input type="text" name="modules-0-title" value="Kitchen Prep" maxlength="200" id="id_modules-0-title">
</p>
<p>
<label for="id_modules-0-description">Description:</label>
<textarea name="modules-0-description" cols="40" rows="10" id="id_modules-0-description">
If you don&#x27;t have the right kitchen, you&#x27;re DOOMED.
</textarea>
</p>
<p>
<label for="id_modules-0-DELETE">Delete:</label>
<input type="checkbox" name="modules-0-DELETE" id="id_modules-0-DELETE">
<input type="hidden" name="modules-0-id" value="6" id="id_modules-0-id">
<input type="hidden" name="modules-0-course" value="7" id="id_modules-0-course">
</p>
<p>
<label for="id_modules-1-title">Title:</label>
<input type="text" name="modules-1-title" value="Ingredients" maxlength="200" id="id_modules-1-title">
</p>
<p><label for="id_modules-1-description">Description:</label>
<textarea name="modules-1-description" cols="40" rows="10" id="id_modules-1-description">
Open up those cupboards, because things are about to get messy.,
</textarea>
</p>
<p>
<label for="id_modules-1-DELETE">Delete:</label>
<input type="checkbox" name="modules-1-DELETE" id="id_modules-1-DELETE">
<input type="hidden" name="modules-1-id" value="7" id="id_modules-1-id">
<input type="hidden" name="modules-1-course" value="7" id="id_modules-1-course">
</p>
<p>
<label for="id_modules-2-title">Title:</label>
<input type="text" name="modules-2-title" value="The right dishes" maxlength="200" id="id_modules-2-title">
</p>
<p>
<label for="id_modules-2-description">Description:</label>
<textarea name="modules-2-description" cols="40" rows="10" id="id_modules-2-description">
You need the right equipment. If you don&#x27;t have it, buy it. If you can&#x27;t afford it, too bad, DO IT.
</textarea>
</p>
<p>
<label for="id_modules-2-DELETE">Delete:</label>
<input type="checkbox" name="modules-2-DELETE" id="id_modules-2-DELETE">
<input type="hidden" name="modules-2-id" value="8" id="id_modules-2-id">
<input type="hidden" name="modules-2-course" value="7" id="id_modules-2-course">
</p>
<p>
<label for="id_modules-3-title">Title:</label>
<input type="text" name="modules-3-title" maxlength="200" id="id_modules-3-title">
</p>
<p><label for="id_modules-3-description">Description:</label>
<textarea name="modules-3-description" cols="40" rows="10" id="id_modules-3-description"></textarea>
</p>
<p>
<label for="id_modules-3-DELETE">Delete:</label>
<input type="checkbox" name="modules-3-DELETE" id="id_modules-3-DELETE">
<input type="hidden" name="modules-3-id" id="id_modules-3-id">
<input type="hidden" name="modules-3-course" value="7" id="id_modules-3-course">
</p>
<p>
<label for="id_modules-4-title">Title:</label>
<input type="text" name="modules-4-title" maxlength="200" id="id_modules-4-title">
</p>
<p>
<label for="id_modules-4-description">Description:</label>
<textarea name="modules-4-description" cols="40" rows="10" id="id_modules-4-description"></textarea>
</p>
<p>
<label for="id_modules-4-DELETE">Delete:</label>
<input type="checkbox" name="modules-4-DELETE" id="id_modules-4-DELETE">
<input type="hidden" name="modules-4-id" id="id_modules-4-id">
<input type="hidden" name="modules-4-course" value="7" id="id_modules-4-course">
</p>
<input type="hidden" name="modules-TOTAL_FORMS" value="5" id="id_modules-TOTAL_FORMS">
<input type="hidden" name="modules-INITIAL_FORMS" value="3" id="id_modules-INITIAL_FORMS">
<input type="hidden" name="modules-MIN_NUM_FORMS" value="0" id="id_modules-MIN_NUM_FORMS">
<input type="hidden" name="modules-MAX_NUM_FORMS" value="1000" id="id_modules-MAX_NUM_FORMS">
<input type="submit" class="button" value="Save modules">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment