F
F
fatalixan2020-05-08 10:56:41
Django
fatalixan, 2020-05-08 10:56:41

How to rewrite what is written by get_object() using the get() method - the task is that if there is no profile, then redirect to create a profile?

class MyProfile(DetailView):
template_name = 'profile.html'

def get_object(self):
return self.request.user.profile

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-05-08
@fatalixan

Well, check the availability of the profile, it is very well described in the docks about OneToOneField.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question