How can I include user profile's images/logos on django comments -


I posted it to the dingo-user but I could not find any answer!

That's why I have one of my own profile objects (sub-categories of user) for the image field, which is (obviously) used to upload users to their logo / thumbnails.

The question is how can I include it on their comments?

Any thoughts? Thanks in advance!

The subclassing user is not recommended in the Django. Instead, create a different profile model.

Let's say your app is foo .

In FU models.py , add:

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

Then, add your Settings.py , to:

  AUTH_PROFILE_MODULE = ' Foo.FooUserProfile ' 

Now, whenever you have a user object, you can get its Profile object with the Get_profile () function. In your case, you can add to the template:

  & lt; Img src = "{{comment.user.get_profile.user_image}}" /> A warning: At any time, you have to make a user a Fuaser profile and you have to add it to your user to create a new user. 

You can read more in the Django documentation, or

in the article

Comments