[Answered ]-Add attribute to admin model Django

0๐Ÿ‘

โœ…

I figured out that in my view (TokenView) Iโ€™m referencing to the Auth user and not the User Model in my models.

So to add another attributes to the Authenticating user (provided by Django by default), I must associate the Auth user to another model and add the attributes I want, I found it here : Django Profiles

from django.db import models
from django.contrib.auth.models import User


class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    activity = models.IntegerField(default=500)

    def _str_(self):
        return self
๐Ÿ‘คOussama Eddahri

1๐Ÿ‘

Please go into your root directory and delete all migrations from the root directory leaving only init file then go back into your command console and apply the migrations before you sync it to your database with migrate. Your from problem seems to come from the โ€“fake migrate as it does not actually sync it to the databased.

๐Ÿ‘คGodda

Leave a comment