Skip to content

Commit 9286c9c

Browse files
Add compatibility with custom user models
1 parent 9408288 commit 9286c9c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ninja_apikey/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def is_valid(self):
2929
return self.expires_at >= timezone.now()
3030

3131
def __str__(self):
32-
return f"{self.user.username}<{self.prefix}>"
32+
return f"{self.user.get_username()}<{self.prefix}>"

ninja_apikey/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_apikey_check():
5353
key.hashed_key = key_data.hashed_key
5454
key.save()
5555
assert key
56-
assert user.username in str(key)
56+
assert user.get_username() in str(key)
5757
assert not check_apikey(key_data.key)
5858
assert not check_apikey(key.prefix)
5959
assert not check_apikey(f"{key_data.prefix}.{get_random_string(10)}")

0 commit comments

Comments
 (0)