0

I'm trying to display the user profile but I keep getting this error? I'm suspecting something is wrong in the urls/views. I've tried following this get user profile in django

Here is my my models.py

class DoctorSeeker(models.Model):
    name = models.CharField(max_length=30)
    email = models.EmailField()
    user = models.OneToOneField(User, unique=True)

    def __unicode__(self):
        return u"%s %s" % (self.name, self.email)

def create_seeker_profile(sender, instance, created, **kwargs):
    if created:
        DoctorSeeker.objects.get_or_create(user=instance)

post_save.connect(create_seeker_profile, sender=User)

views.py

def showProfile(request):
    profile = request.user.get_profile()
    return render(request,'/profile.html')

urls.py

 url(r'^profile/(?P<id>\d+)/$', views.showProfile, name='showProfile'),

This is where I'm trying to access it through in my header

<li><a href="/profile/{{user.id}}">My Profile</a></li>

1 Answer 1

1

In your urls, you define id, and pass it to the view handler showProfile, but the view handler signature is wrong.

Change the view handler, add argument id to it, after request:

def showProfile(request, id):
    profile = request.user.get_profile()
    return render(request,'/profile.html')
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.