diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 64d71fe..1597d3c 100644
|
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
| 552 | 552 | """ |
| 553 | 553 | from django.contrib.admin.models import LogEntry, DELETION |
| 554 | 554 | LogEntry.objects.log_action( |
| 555 | | user_id = request.user.id, |
| | 555 | user_id = request.user.pk, |
| 556 | 556 | content_type_id = ContentType.objects.get_for_model(self.model).pk, |
| 557 | 557 | object_id = object.pk, |
| 558 | 558 | object_repr = object_repr, |
diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py
index 5dbda44..99348d3 100644
|
a
|
b
|
def login(request, user):
|
| 84 | 84 | user = request.user |
| 85 | 85 | # TODO: It would be nice to support different login methods, like signed cookies. |
| 86 | 86 | if SESSION_KEY in request.session: |
| 87 | | if request.session[SESSION_KEY] != user.id: |
| | 87 | if request.session[SESSION_KEY] != user.pk: |
| 88 | 88 | # To avoid reusing another user's session, create a new, empty |
| 89 | 89 | # session if the existing session corresponds to a different |
| 90 | 90 | # authenticated user. |
| 91 | 91 | request.session.flush() |
| 92 | 92 | else: |
| 93 | 93 | request.session.cycle_key() |
| 94 | | request.session[SESSION_KEY] = user.id |
| | 94 | request.session[SESSION_KEY] = user.pk |
| 95 | 95 | request.session[BACKEND_SESSION_KEY] = user.backend |
| 96 | 96 | if hasattr(request, 'user'): |
| 97 | 97 | request.user = user |
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 9279c52..10d9eca 100644
|
a
|
b
|
class PasswordResetForm(forms.Form):
|
| 241 | 241 | 'email': user.email, |
| 242 | 242 | 'domain': domain, |
| 243 | 243 | 'site_name': site_name, |
| 244 | | 'uid': int_to_base36(user.id), |
| | 244 | 'uid': int_to_base36(user.pk), |
| 245 | 245 | 'user': user, |
| 246 | 246 | 'token': token_generator.make_token(user), |
| 247 | 247 | 'protocol': use_https and 'https' or 'http', |
diff --git a/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html b/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html
index aa7f784..dc4c6b1 100644
|
a
|
b
|
|
| 1 | 1 | unicode: {{ user }} |
| 2 | | id: {{ user.id }} |
| | 2 | id: {{ user.pk }} |
| 3 | 3 | username: {{ user.username }} |
| 4 | 4 | url: {% url 'userpage' user %} |
diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py
index 930c700..6e5bfe7 100644
|
a
|
b
|
class PasswordResetTokenGenerator(object):
|
| 58 | 58 | # Ensure results are consistent across DB backends |
| 59 | 59 | login_timestamp = user.last_login.replace(microsecond=0, tzinfo=None) |
| 60 | 60 | |
| 61 | | value = (six.text_type(user.id) + user.password + |
| | 61 | value = (six.text_type(user.pk) + user.password + |
| 62 | 62 | six.text_type(login_timestamp) + six.text_type(timestamp)) |
| 63 | 63 | hash = salted_hmac(key_salt, value).hexdigest()[::2] |
| 64 | 64 | return "%s-%s" % (ts_b36, hash) |
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index d27e2f5..2562a63 100644
|
a
|
b
|
def password_reset_confirm(request, uidb36=None, token=None,
|
| 206 | 206 | post_reset_redirect = reverse('django.contrib.auth.views.password_reset_complete') |
| 207 | 207 | try: |
| 208 | 208 | uid_int = base36_to_int(uidb36) |
| 209 | | user = UserModel.objects.get(id=uid_int) |
| | 209 | user = UserModel.objects.get(pk=uid_int) |
| 210 | 210 | except (ValueError, OverflowError, UserModel.DoesNotExist): |
| 211 | 211 | user = None |
| 212 | 212 | |
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index ba43e2e..0098037 100644
|
a
|
b
|
Output the contents of the block if the two arguments equal each other.
|
| 618 | 618 | |
| 619 | 619 | Example:: |
| 620 | 620 | |
| 621 | | {% ifequal user.id comment.user_id %} |
| | 621 | {% ifequal user.pk comment.user_id %} |
| 622 | 622 | ... |
| 623 | 623 | {% endifequal %} |
| 624 | 624 | |
diff --git a/tests/regressiontests/model_formsets_regress/tests.py b/tests/regressiontests/model_formsets_regress/tests.py
index 1fbdb97..8cadcfc 100644
|
a
|
b
|
class FormfieldShouldDeleteFormTests(TestCase):
|
| 351 | 351 | |
| 352 | 352 | def should_delete(self): |
| 353 | 353 | """ delete form if odd PK """ |
| 354 | | return self.instance.id % 2 != 0 |
| | 354 | return self.instance.pk % 2 != 0 |
| 355 | 355 | |
| 356 | 356 | NormalFormset = modelformset_factory(User, form=CustomDeleteUserForm, can_delete=True) |
| 357 | 357 | DeleteFormset = modelformset_factory(User, form=CustomDeleteUserForm, formset=BaseCustomDeleteModelFormSet) |
| … |
… |
class FormfieldShouldDeleteFormTests(TestCase):
|
| 392 | 392 | data = dict(self.data) |
| 393 | 393 | data['form-INITIAL_FORMS'] = 4 |
| 394 | 394 | data.update(dict( |
| 395 | | ('form-%d-id' % i, user.id) |
| | 395 | ('form-%d-id' % i, user.pk) |
| 396 | 396 | for i,user in enumerate(User.objects.all()) |
| 397 | 397 | )) |
| 398 | 398 | formset = self.NormalFormset(data, queryset=User.objects.all()) |
| … |
… |
class FormfieldShouldDeleteFormTests(TestCase):
|
| 409 | 409 | data = dict(self.data) |
| 410 | 410 | data['form-INITIAL_FORMS'] = 4 |
| 411 | 411 | data.update(dict( |
| 412 | | ('form-%d-id' % i, user.id) |
| | 412 | ('form-%d-id' % i, user.pk) |
| 413 | 413 | for i,user in enumerate(User.objects.all()) |
| 414 | 414 | )) |
| 415 | 415 | data.update(self.delete_all_ids) |
| … |
… |
class FormfieldShouldDeleteFormTests(TestCase):
|
| 428 | 428 | data = dict(self.data) |
| 429 | 429 | data['form-INITIAL_FORMS'] = 4 |
| 430 | 430 | data.update(dict( |
| 431 | | ('form-%d-id' % i, user.id) |
| | 431 | ('form-%d-id' % i, user.pk) |
| 432 | 432 | for i,user in enumerate(User.objects.all()) |
| 433 | 433 | )) |
| 434 | 434 | data.update(self.delete_all_ids) |
| … |
… |
class FormfieldShouldDeleteFormTests(TestCase):
|
| 440 | 440 | self.assertEqual(len(User.objects.all()), 2) |
| 441 | 441 | |
| 442 | 442 | # verify no "odd" PKs left |
| 443 | | odd_ids = [user.id for user in User.objects.all() if user.id % 2] |
| | 443 | odd_ids = [user.pk for user in User.objects.all() if user.pk % 2] |
| 444 | 444 | self.assertEqual(len(odd_ids), 0) |
diff --git a/tests/regressiontests/transactions_regress/tests.py b/tests/regressiontests/transactions_regress/tests.py
index 66e0477..5d1ab2c 100644
|
a
|
b
|
class TestTransactionClosing(TransactionTestCase):
|
| 140 | 140 | "Create a user in a transaction" |
| 141 | 141 | user = User.objects.create_user(username='system', password='iamr00t', email='root@SITENAME.com') |
| 142 | 142 | # Redundant, just makes sure the user id was read back from DB |
| 143 | | Mod.objects.create(fld=user.id) |
| | 143 | Mod.objects.create(fld=user.pk) |
| 144 | 144 | |
| 145 | 145 | # Create a user |
| 146 | 146 | create_system_user() |