Pompeyo
Pompeyo

Reputation: 1469

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

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!

Upvotes: 1

Views: 543

Answers (2)

Chris Hawkes
Chris Hawkes

Reputation: 12420

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.

Upvotes: 1

Guy Gavriely
Guy Gavriely

Reputation: 11396

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...

Upvotes: 1

Related Questions