Skip to content

Instantly share code, notes, and snippets.

@jakul
Created April 9, 2014 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakul/10281171 to your computer and use it in GitHub Desktop.
Save jakul/10281171 to your computer and use it in GitHub Desktop.
if numbers.count() > 0:
phone_no_1 = numbers[0]
else:
phone_no_1 = PhoneNumber()
phone_no_1.content_object = self.instance.user
phone_no_1.number = self.cleaned_data['phone_no_1']
# ensure this one is marked as the default one
phone_no_1.is_default = True
phone_no_1.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment