How to include images / logos of user profile in django comments

I posted this on django users but didn't get a response!

So, I have my own profile objects for users (subclass of User). One of the fields is imagefield, which (obviously) is used to let users upload their logo / thumbnail.

The question is, how can I include this in my comments?

Any ideas? Thank you in advance!

+3
source share
1 answer

Django does not recommend subclassing a user. Instead, create a separate profile model.

Suppose you have your application, foo.

In foo models.py add:

class FooUserProfile(models.Model):
   user = models.ForeignKey(User, unique=True)
   user_image = models.ImageField()

Then in the settings.py file add:

AUTH_PROFILE_MODULE = 'foo.FooUserProfile'

, , get_profile(). :

<img src="{{ comment.user.get_profile.user_image }}"/>

: FooUserProfile .

Django Django:

+9

Source: https://habr.com/ru/post/1702434/


All Articles