1

How I create new Users:

from twittexApp.forms import UserCreationForm from django.views.generic import CreateView from twittexApp.models import RegUser, User class RegisterView(CreateView): template_name = 'register.html' model = RegUser success_url = '/login/' form_class = UserCreationForm 

My extended User Model:

from django.db import models from django.contrib.auth.models import User class RegUser(models.Model): user = models.OneToOneField(User) description = models.CharField(max_length = 140, default="foo") 

My question is how do I get the attribute "description" from an user?

I already know that I can get the "standard" user model via

<h1>My Profile</h1> <ul> <div>{{ request.user.username }}</div> </ul> 

But getting the description doesnt work. I tried 2 different versions but it doesnt show "foo".

<h1>My Profile</h1> <ul> <div>{{ request.user.desciption }}</div> <div>{{ request.user.reguser.desciption }}</div> </ul> 
1
  • desciption != description Commented Jun 6, 2015 at 0:38

2 Answers 2

2

Maybe is a fool answer but you have a miss spell.

Change:

{{ request.user.desciption }}

For this:

{{ request.user.description }}
Sign up to request clarification or add additional context in comments.

Comments

1
{{ request.user.reguser.description }} 

You can access "reverse" side of the relation. In this case user.reguser. Also check, if user has related RegUser instance.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.