Django

Code

Show
Ignore:
Timestamp:
09/15/07 20:57:25 (1 year ago)
Author:
mtredinnick
Message:

Fixed #3703 -- Added pk property to models. Thanks, Collin Grady and jeromie@gmail.com.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/modeltests/custom_pk/models.py

    r6200 r6346  
    5757[<Employee: Fran Bones>, <Employee: Dan Jones>] 
    5858 
     59# The primary key can be accessed via the pk property on the model. 
     60>>> e = Employee.objects.get(pk='ABC123') 
     61>>> e.pk 
     62u'ABC123' 
     63 
     64# Or we can use the real attribute name for the primary key: 
     65>>> e.employee_code 
     66u'ABC123' 
     67 
    5968# Fran got married and changed her last name. 
    6069>>> fran = Employee.objects.get(pk='XYZ456')