~ubuntu-branches/ubuntu/utopic/python-django/utopic

« back to all changes in this revision

Viewing changes to django/db/models/fields/related.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2013-02-24 10:28:08 UTC
  • mfrom: (1.1.20) (4.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20130224102808-mtc8rkfx42wro0oz
* New upstream maintenance release dropping some undesired .pyc files
  and fixing a documentation link.
* High urgency due to former security updates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
544
544
                                 "a many-to-many relationship can be used." %
545
545
                                 instance.__class__.__name__)
546
546
 
547
 
 
548
547
        def _get_fk_val(self, obj, field_name):
549
548
            """
550
549
            Returns the correct value for this relationship's foreign key. This
551
550
            might be something else than pk value when to_field is used.
552
551
            """
 
552
            if not self.through:
 
553
                # Make custom m2m fields with no through model defined usable.
 
554
                return obj.pk
553
555
            fk = self.through._meta.get_field(field_name)
554
556
            if fk.rel.field_name and fk.rel.field_name != fk.rel.to._meta.pk.attname:
555
557
                attname = fk.rel.get_related_field().get_attname()