Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 3f27606e18
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (20 sloc) 0.906 kB
from django import forms
from django.template.loader import render_to_string
from django.contrib.admin.widgets import FilteredSelectMultiple
class PopUpBaseWidget(object):
def __init__(self, model=None, template='addnew.html', *args, **kwargs):
self.model = model
self.template = template
super(PopUpBaseWidget, self).__init__(*args, **kwargs)
def render(self, name, *args, **kwargs):
html = super(PopUpBaseWidget, self).render(name, *args, **kwargs)
if not self.model:
self.model = name
popupplus = render_to_string(self.template, {'field': name, 'model': self.model})
return html+popupplus
class FilteredMultipleSelectWithPopUp(PopUpBaseWidget, FilteredSelectMultiple):
pass
class MultipleSelectWithPopUp(PopUpBaseWidget, forms.SelectMultiple):
pass
class SelectWithPopUp(PopUpBaseWidget, forms.Select):
pass
Jump to Line
Something went wrong with that request. Please try again.