#NEWLINE# def render( self , name , value , attrs ) : #NEWLINE# #INDENT# urls = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for m in admin . site . _registry : #NEWLINE# #INDENT# urls [ model_path ( m ) ] = reverse ( ( 'admin:%s_%s_changelist' % ( m . _meta . app_label , m . _meta . module_name ) ) ) #NEWLINE# #UNINDENT# urls = json . dumps ( urls ) #NEWLINE# safe_name = name . replace ( '-' , '_' ) #NEWLINE# extra = [ ] #NEWLINE# extra . append ( ( '<script type="text/javascript">var urls = %s; function popup_%s(trigger) {\n            var name = trigger.id.replace(/^lookup_/, \'\');\n            name = id_to_windowname(name);\n            var chosen_model = django.jQuery(trigger).siblings(\'select\').val();\n            if (chosen_model in urls) {\n                var href = urls[chosen_model] + \'?pop=1\'\n                var win = window.open(href, name, \'height=500,width=800,resizable=yes,scrollbars=yes\');\n                win.focus();\n            }\n            return false;\n            }\n        </script>\n' % ( urls , safe_name ) ) ) #NEWLINE# extra . append ( ( '<a href="" class="related-lookup" id="lookup_id_%s" onclick="return popup_%s(this);"> ' % ( name , safe_name ) ) ) #NEWLINE# extra . append ( ( '<img src="%s" width="16" height="16" alt="%s" /></a>' % ( static ( 'admin/img/selector-search.gif' ) , 'Lookup' ) ) ) #NEWLINE# output = ( [ super ( GenericFKInput , self ) . render ( name , value , attrs ) ] + extra ) #NEWLINE# return mark_safe ( '' . join ( output ) )