I think the problem is that you're trying to get from the class and
not from the instance of the class. So insted of doing that, you
should do something like this:
user = User.objects.get(first_name=bar, last_name=foo)
user.first_name
Of course for doing that you should first get bar and foo (through the
URL, or request.POST, or request.GET)
But I think that what you're looking instead of all that crap is
request.user, so you should do this:
fullname=request.user.first_name + ' ' + request.user.last_name
Or even better:
fullname=request.user.get_full_name
You can skip that step and do this:
def ShowMainMenu (request):
return render_to_response('scanning/menu.html',
{'fullname': request.user.get_full_name,},
context_instance=RequestContext(request))
Or skip the fullname stuff and getting the atribute directly in the
template: {{request.user.get_full_name }}
Don't forget the login_required decorator, because if an anonymous
user try to get that page he will get an exception (I think, didn't
try that)
No, they will be redirected to login and after login they come back to the original page, if the form considers the ’next’ field. How nice is that!?
Yeah, I know, the 'next' magic, with GET or POST, it's veeeery nice ;)
The thing that I was saying is that he should validate that the user
is logged in, (login_required decorator, or
request.user.is_authenticated), because if he doesn't then he will
have an anonymous user instance, and I think that isn't what he
wants...
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'.
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
good luck,
TR
------------------------------------------------