Munch simpler solution using link-button.
This commit is contained in:
		@@ -10,12 +10,14 @@
 | 
				
			|||||||
        <legend class="LP-Form__Legend">Place löschen</legend>
 | 
					        <legend class="LP-Form__Legend">Place löschen</legend>
 | 
				
			||||||
        {% csrf_token %}
 | 
					        {% csrf_token %}
 | 
				
			||||||
        <div class="LP-Form__Composition LP-Form__Composition--breakable">
 | 
					        <div class="LP-Form__Composition LP-Form__Composition--breakable">
 | 
				
			||||||
			<p class="LP-Paragraph">Are you sure you want to delete "{{place.name}}"?</p>
 | 
					            <p class="LP-Paragraph">Are you sure you want to delete "{{place.name}}"?</p>
 | 
				
			||||||
			<div class="LP-Form__Composition">
 | 
					            <div class="LP-Form__Composition">
 | 
				
			||||||
				<input type="submit" class="LP-Button LP-Button--cancel" name="cancel" value="Cancel"/>
 | 
					                <a href="{% url 'place_detail' pk=place.pk %}"
 | 
				
			||||||
				<input type="submit" class="LP-Button" name="Delete" value="Delete"/>
 | 
					                    <button class="LP-Button LP-Button--cancel">Cancel</button>
 | 
				
			||||||
			</div>
 | 
					                </a>
 | 
				
			||||||
		</div>
 | 
					                <input type="submit" class="LP-Button" value="Delete"/>
 | 
				
			||||||
	</fieldset>
 | 
					            </div>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </fieldset>
 | 
				
			||||||
</form>
 | 
					</form>
 | 
				
			||||||
{% endblock maincontent %}
 | 
					{% endblock maincontent %}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -98,10 +98,6 @@ class PlaceCreateView(View):
 | 
				
			|||||||
class PlaceDeleteView(DeleteView):
 | 
					class PlaceDeleteView(DeleteView):
 | 
				
			||||||
    template_name = 'place/place_delete.html'
 | 
					    template_name = 'place/place_delete.html'
 | 
				
			||||||
    model = Place
 | 
					    model = Place
 | 
				
			||||||
    success_url = reverse_lazy('place_list')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def post(self, request, *args, **kwargs):
 | 
					    def get_success_url(self):
 | 
				
			||||||
        if "cancel" in request.POST:
 | 
					        return reverse_lazy('place_list')
 | 
				
			||||||
            return redirect(self.success_url)
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            return super(PlaceDeleteView, self).post(request, *args, **kwargs)
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user