From 7443d76a2f7e5cdd163056135e0ee0833870d40f Mon Sep 17 00:00:00 2001 From: "Fabian P. Schmidt" Date: Tue, 31 Dec 2019 22:46:42 +0100 Subject: [PATCH] users/models: Replace __unicode__ by __str__ (W5102) The special method __unicode__ is python2-only, in python3 it's merged with __str__. In order to be py23-compatible the python_2_unicode_compatible decorator is used, see https://docs.djangoproject.com/en/1.11/topics/python3/#str-and-unicode-methods Equivalent commit in db: librespacefoundation/satnogs/satnogs-db@9a0ef30e Equivalent commit for base model: d20943ce Signed-off-by: Fabian P. Schmidt --- network/users/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/network/users/models.py b/network/users/models.py index b840827..006db93 100644 --- a/network/users/models.py +++ b/network/users/models.py @@ -5,6 +5,7 @@ from django.contrib.auth.models import AbstractUser from django.core.validators import MaxLengthValidator from django.db import models from django.db.models.signals import post_save +from django.utils.encoding import python_2_unicode_compatible from rest_framework.authtoken.models import Token @@ -16,6 +17,7 @@ def gen_token(sender, instance, created, **kwargs): # pylint: disable=W0613 Token.objects.create(user=instance) +@python_2_unicode_compatible class User(AbstractUser): """Model for SatNOGS users.""" @@ -28,7 +30,7 @@ class User(AbstractUser): return self.get_full_name() return self.username - def __unicode__(self): + def __str__(self): return self.username