Django: check whether an object already exists before adding

/ Published in: Django
Save to your folder(s)

Copy this code and paste it in your HTML
  1. role, created = UserToUserRole.objects.get_or_create(
  2. from_user=current_user, to_user=user, role='follow')


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.