Snippet List
**CancelMixin**
A simple mixin to use with ```generic.CreateView``` and ```generic.UpdateView``` view form templates to effortlessly implement a "Cancel" button.
This smart mixin will add a URL to your context, ```{{ cancel_url }}```, that can be used as a cancel link in your form template. If no referrer URL is provided, the cancel button will link to ```default_cancel_url```, which can be overridden by view.
** **
- template
- django
- mixin
- update
- create
- cbv
**What It Is**
This is a JavaScript-based solution to dynamically add and remove forms in formsets and inlineformsets. It requires jQuery.
Originally based on this Snippet: https://djangosnippets.org/snippets/1389/
I have done a lot of work to make it OO, and am using it in production on pages with multiple inlineformsets, and even nested inlineformsets (I call it, "Inlineformset Inception").
My hope is that the code and example are enough to show how it works.
**Usage Details**
In the example usage, I am using a CSS class, 'light', to make every other form have a light background color. My form placeholder is an element with an ID of 'formset-placeholder' (the default). And the form selector is a class name of 'dynamic-form' (the default).
When I have time, I will create a GitHub repository with the code and completed examples.
- django
- javascript
- jquery
- formset
- inlineformset
halfnibble has posted 2 snippets.