hi i am a newbie in django i am creating an app with customuser and profile
i want get user profile information in templates who is logged in.
try everypossible solution but didn't achieve anything
this is my profile models code below:
from django.db import models
from django.utils.translation import ugettext_lazy as _
from CustomUserAuth.models import CustomUser
class ProfileModel(models.Model):
user = models.OneToOneField(CustomUser)
avatar = models.ImageField(_('Profile Pic'),upload_to='images/')
first_name = models.CharField(_('First Name'),max_length=100)
last_name = models.CharField(_('Last Name'),max_length=100)
company = models.CharField(_('Company'),max_length=100)
title = models.CharField(_('Title'),max_length=100)
def __str__(self):
return '%s %s' % (self.first_name,self.last_name)
def image_tag(self):
return u'<img src="%s"/>' % (self.avatar.url)
image_tag.short_description = 'Image'
image_tag.allow_tags = True
CustomUser.profile = property(lambda u: ProfileModel.objects.get_or_create(user=u)[0])