Dimitris Kougioumtzis Blog About technology

django popup mixin

Category Django

Posted on Sept. 12, 2017



django popup mixin use with class based views


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from django.utils.html import escape

class RelatedMixin(object):

    def form_valid(self, form):
        popup = self.request.GET.get('popup', None)
        if popup:
            return HttpResponse(
               "<script type='text/javascript'>
                opener.dismissAddAnotherPopup(window, '%s', '%s');
                </script>" %
                (escape(form.instance.pk), escape(form.instance)))
        return super(RelatedMixin, self).form_valid(form)

About

My name is Dimitris Kougioumtzis and i work as a Web developer at Rapidbounce Company

Elsewhere