1obj, created = Person.objects.update_or_create(
2 first_name='John', last_name='Lennon',
3 defaults={'first_name': 'Bob'},
4)
5# If person exists with first_name='John' & last_name='Lennon' then update first_name='Bob'
6# Else create new person with first_name='Bob' & last_name='Lennon'
7
1def get_absolute_url(self):
2 from django.core.urlresolvers import reverse
3 return reverse('', kwargs={'pk': self.pk})