+ def redirect_or_refresh(self, request, path, message=None):
+ """If the form is AJAX, refresh the page. If not, go to `path`."""
+ if request.is_ajax():
+ output = "<script>window.location.reload()</script>"
+ if message:
+ output = "<div class='normal-text'>" + message + "</div>" + output
+ return HttpResponse(output)
+ else:
+ return HttpResponseRedirect(path)
+
+ def get_object(self, request, *args, **kwargs):
+ """Override to parse view args and get some associated data."""
+ return None
+
+ def form_args(self, request, obj):
+ """Override to parse view args and give additional args to the form."""
+ return (), {}
+
+ def extra_context(self, request, obj):
+ """Override to pass something to template."""
+ return {}
+
+ def context_description(self, request, obj):
+ """Description to appear in standalone form, but not in AJAX form."""
+ return ""
+