Reputation: 141
Views.py
class ProfileView(UserPassesTestMixin, DetailView):
template_name = "profile/profile_view.html"
queryset = User.objects.all()
context_object_name = 'profile'
def test_func(self):
x = self.request.user.full_name
print (x)
y = ''
if x == y:
raise Http404("Profile Inactive")
else:
return True
Question - If the full_name
of the user is empty i want to display Profile Inactive
error but i am not able to print the full_name
. I don't want to print the full_name
of the logged in user but the user's page. the user's page is defined by slug localhost:8000/slug
.
Upvotes: 2
Views: 4186
Reputation: 5919
You can use self.get_object()
to get the object based on the lookup field.
Upvotes: 2