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.
No comments:
Post a Comment