Ticket #3737: auto_populate_fields_from_filters.patch
File auto_populate_fields_from_filters.patch, 1.9 KB (added by , 18 years ago) |
---|
-
contrib/admin/templates/admin/change_list.html
9 9 <div id="content-main"> 10 10 {% block object-tools %} 11 11 {% if has_add_permission %} 12 <ul class="object-tools"><li><a href="add/{ % if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li></ul>12 <ul class="object-tools"><li><a href="add/{{cl.get_add_query_string}}{% if is_popup %}&_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li></ul> 13 13 {% endif %} 14 14 {% endblock %} 15 15 <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist"> -
contrib/admin/views/main.py
599 599 elif v is not None: 600 600 p[k] = v 601 601 return '?' + '&'.join(['%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20') 602 602 603 def get_add_query_string(self): 604 from django.db.models import query 605 606 p = self.params.copy() 607 608 new_query_dict = {} 609 for k in p.keys(): 610 path = k.split(query.LOOKUP_SEPARATOR) 611 lookup_type = path.pop() 612 if len(path) == 0 or lookup_type not in query.QUERY_TERMS: 613 path.append(lookup_type) 614 new_query_dict["_".join(path)] = p[k] 615 return '?' + '&'.join(['%s=%s' % (k, v) for k, v in new_query_dict.items()]).replace(' ', '%20') 616 603 617 def get_results(self, request): 604 618 paginator = ObjectPaginator(self.query_set, self.lookup_opts.admin.list_per_page) 605 619