Thursday, February 3, 2011

Re: user full name in template

which django version do you use?

the current 'head' version shows in django/contrib/auth/models.py:

---8<---

200 class User(models.Model):
201 """
202 Users within the Django authentication system are represented by this model.
203
204 Username and password are required. Other fields are optional.
205 """
206 username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters"))
207 first_name = models.CharField(_('first name'), max_length=30, blank=True)
208 last_name = models.CharField(_('last name'), max_length=30, blank=True)
209 email = models.EmailField(_('e-mail address'), blank=True)

...

---8<---

So there is an attribute called 'first_name'

But, I think the fault is more Python related.

You will need to deal with an existing object of the class 'User'.

Am 04.02.2011 um 06:24 schrieb Bobby Roberts:

> here's what i'm trying
>
> from django.contrib.auth import authenticate, login, logout
> #import django user modules
> from django.contrib.auth.models import User
>
> def ShowMainMenu (request):
> fullname=User.first_name + ' ' + User.last_name
> return render_to_response('scanning/menu.html',
> {'fullname':fullname}, context_instance=RequestContext(request))
>
> I'm getting this err:
>
> type object 'User' has no attribute 'first_name'
>
>
>
> On Feb 4, 12:15 am, arlolra <arlo...@gmail.com> wrote:
>> user.get_full_name should workhttps://github.com/django/django/blob/master/django/contrib/auth/mode...
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

good luck,
TR

------------------------------------------------

http://thoreg.org


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment