Friday, November 13, 2020

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

Yes I believe so I did programming years ago but from the error code you are getting I would say try that because the syntex can not process what it does not have. It is telling you it do not have an attribute named user there it can not return such output, so yes try the module area to put in the user. I hope this helps.

On Fri, Nov 13, 2020 at 5:22 PM Apolo Machine <apolomachine@gmail.com> wrote:
where? in my model service?
i'm not quiet understand
thanks for responding

El vie., 13 nov. 2020 a las 18:53, Barbara Leonard (<barbaraleonard9@gmail.com>) escribió:
make an attribute named "user"

On Fri, Nov 13, 2020 at 2:27 PM Apolo Machine <apolomachine@gmail.com> wrote:
I'm trying to get the username within a view(CBV), the documentation I found says that the logged user is within the request, but when I do

class ServiceCreateView(LoginRequiredMixin, CreateView):
          model = Service
          form_class = ServiceForm
          user=request.user.username

i get this error

AttributeError: module 'django.http.request' has no attribute 'user

any help is appreciated

--
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/8635848c-b7fc-4b6b-9b53-f6107ce42717n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/jW90KnHwaw0/unsubscribe.
To unsubscribe from this group and all its topics, 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/CAAcuwDfBL82t2WebGvYmUEiP%2BCD7tv3aBTL7f%2BrH0igzVUbSuQ%40mail.gmail.com.


--
::Apolo::

--
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/CALOuZTBP0S3fVSuuqw6v8sc2A67115iwNO_QKh_Ubw265g35DQ%40mail.gmail.com.

--
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/CAAcuwDdKBHWLQoWSmnJLx4MVHg4Jbju5VGPaACFfmrhNNf95bw%40mail.gmail.com.

No comments:

Post a Comment