Hi,

If you just add a custom __str__ (or __unicode__ on py2) it might do what 
you want.

def __str__(self):
    return str(user)

Otherwise, in UserTokenAdmin, set list_display = ['user']

Collin

On Wednesday, March 4, 2015 at 2:15:32 PM UTC-5, Flemming Hansen wrote:
>
> Hi all,
>
> I need to make a `passwordless` token system, and want to have a "Home › 
> Passwordless › User tokens" in the Admin section. For the "User tokens" 
> `list_display` I need all the "Users". (I do _not_ want to display the 
> token information on the regular "User"-admin as just an extended 
> "profile".) 
>
> Any ideas on how to go about doing this?
>
> So far I have this skeleton in `passwordless/model.py`, but I probably 
> need some magic in `passwordless/admin.py` to list all the users with links 
> to a custom token-manager form with custom widgets (create-token button, 
> delete token button etc)...
>
> from django.db import models
> import jwt
>
> class UserTokens(models.Model):
>     class Meta:
>         verbose_name = "User tokens"
>         verbose_name_plural = "User tokens"
>
>     user = models.OneToOneField(User)
>
>
> class TokenBase(models.Model):
>     class Meta:
>         abstract = True
>
>     token = models.CharField(max_length=1000)    
>     created_ts = models.DateTimeField('Date created')
>     expires_ts = models.DateTimeField('Date expired')
>
>     def __str__(self):
>         return self.user.email
>
>
> class AuthenticateToken(TokenBase):
>     manager = models.OneToOneField(UserTokens)
>
>     def validate(self, token):
>         pass    
>
>
> class AuthorizeToken(TokenBase):   
>     manager = models.ForeignKey(UserTokens)
>     revoked_ts = models.DateTimeField('Date revoked')
>
>     def validate(self, token):
>         pass  
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/783e5939-eb30-4f5d-ab9c-29002a5523b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to