KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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()
Tags (comma-separated)
Save Edits
Cancel