How to use django-avatar with my own User model and not with django.contrib.auth.models.User

StackOverflow https://stackoverflow.com/questions/20448150

  •  30-08-2022
  •  | 
  •  

Question

I would like to use django-avatar with my own model. Is it possible to do that?

login/models.py

class LoginInfo(models.Model):
    real_name = models.CharField(max_length=100, null=True, blank=True)
    website = models.URLField(blank=True, null=True)
    birthday = models.DateField(null=True, blank=True)
    login = models.OneToOneField(Login, primary_key=True) # contain user_name, pw, mail

Thanks for the help!

Was it helpful?

Solution

check out django-avatar models.py

66. class Avatar(models.Model):
67.     user = models.ForeignKey(getattr(settings, 'AUTH_USER_MODEL', 'auth.User'))
68.     ....

the code seem to be ready to accept custom User model, however, you can always git clone and change it as you wish...

OTHER TIPS

Another option for a simple avatar is django-easy-avatar. It has just has a foreign key relationship to the user table and requires no templates unless you want to override default functionality.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top