from rest_framework.authtoken.models import Token

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


def gen_token(sender, instance, created, **kwargs):
    try:
        Token.objects.get(user=instance)
    except:
        Token.objects.create(user=instance)


class User(AbstractUser):
    """Model for SatNOGS users."""

    bio = models.TextField(default='', validators=[MaxLengthValidator(1000)])

    @property
    def displayname(self):
        if self.get_full_name():
            return self.get_full_name()
        else:
            return self.username

    def __unicode__(self):
        return self.username

post_save.connect(gen_token, sender=User)

from rest_framework.authtoken.models import Token

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


def gen_token(sender, instance, created, **kwargs):
    try:
        Token.objects.get(user=instance)
    except:
        Token.objects.create(user=instance)


class User(AbstractUser):
    """Model for SatNOGS users."""

    bio = models.TextField(default='', validators=[MaxLengthValidator(1000)])

    @property
    def displayname(self):
        if self.get_full_name():
            return self.get_full_name()
        else:
            return self.username

    def __unicode__(self):
        return self.username


post_save.connect(gen_token, sender=User)

Fix user models.py so it passes flake8