Saturday, November 14, 2020

Re: im a newbe, i'm trying to get the username in a view

You would want to include that line in a method, not as a class attribute. For example:

def get(self, request):
        user = request.user.username
        ...
        return render(...


On Sat, Nov 14, 2020 at 9:37 AM Kasper Laudrup <laudrup@stacktrace.dk> wrote:
Hi Barbara,

On 13/11/2020 22.46, Barbara Leonard wrote:
> make an attribute named "user"
>

How would that help? The attribute value should be set to the currently
logged in user. Just adding the attribute to request object will not do
that. Clearly something else is missing.

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/93f48576-7bf0-b46d-9403-5f0c23f3babc%40stacktrace.dk.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACaDatT8mUT142AYWuw6wemqLMzbKjCvZyT%3DAqi-_WoZrYsn9Q%40mail.gmail.com.

No comments:

Post a Comment