This is a pretty simple Django question, but I can't find the answer in the Django docs, despite lots of hunting!
How do I check whether an object already exists, and only add it if it does not already exist?
Here's the code - I don't want to add the follow_role twice in the database if it already exists. How do I check first? Use get() maybe - but then will Django complain if get() doesn't return anything?
current_user = request.user
follow_role = UserToUserRole(from_user=current_user, to_user=user, role='follow')
follow_role.save()
Thanks!