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')

URL: http://stackoverflow.com/questions/1821176/django-check-whether-an-object-already-exists-before-adding

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.