Yes, it’s fine to have your program make that determination - but that determination should be made prior to the view being called.
Is this drop-down part of a form which is being submitted? If so, your POST handler for that form can handle the redirect.
Or is this drop-down handled immediately through an AJAX call? Same idea really - have the endpoint being invoked make the determination.
(I can’t be more specific than this without knowing how they’re getting to that point. What is happening that takes them to that page?)
But, for something like this, you should also want to be aware of race conditions that might occur. What happens if someone goes through this process at the same time as someone else?
More directly, in the simplest case, you could refactor it like this:
def view_function(request, project_id):
check_exist = ...
if check_exist:
return do_update_view(request, project_id)
else:
return do_add_view(request, project_id)
This at least eliminates the redundant conditionals within the views.