~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to django/contrib/admin/options.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2012-08-02 10:44:02 UTC
  • mfrom: (1.2.13)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: package-import@ubuntu.com-20120802104402-pc04sj64wnrf4348
Tags: upstream-1.4.1
Import upstream version 1.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
        # if foo has been specificially included in the lookup list; so
246
246
        # drop __id if it is the last part. However, first we need to find
247
247
        # the pk attribute name.
248
 
        pk_attr_name = None
 
248
        rel_name = None
249
249
        for part in parts[:-1]:
250
250
            try:
251
251
                field, _, _, _ = model._meta.get_field_by_name(part)
255
255
                return True
256
256
            if hasattr(field, 'rel'):
257
257
                model = field.rel.to
258
 
                pk_attr_name = model._meta.pk.name
 
258
                rel_name = field.rel.get_related_field().name
259
259
            elif isinstance(field, RelatedObject):
260
260
                model = field.model
261
 
                pk_attr_name = model._meta.pk.name
 
261
                rel_name = model._meta.pk.name
262
262
            else:
263
 
                pk_attr_name = None
264
 
        if pk_attr_name and len(parts) > 1 and parts[-1] == pk_attr_name:
 
263
                rel_name = None
 
264
        if rel_name and len(parts) > 1 and parts[-1] == rel_name:
265
265
            parts.pop()
266
266
 
267
267
        if len(parts) == 1: