Eliminar objeto modelo django
SomeModel.objects.filter(id=id).delete()
Noobie Nareshhhh
SomeModel.objects.filter(id=id).delete()
Model.objects.filter(id = 223).update(field1 = 2)
obj, created = Person.objects.update_or_create(
first_name='John', last_name='Lennon',
defaults={'first_name': 'Bob'},
)
# If person exists with first_name='John' & last_name='Lennon' then update first_name='Bob'
# Else create new person with first_name='Bob' & last_name='Lennon'
python -m pip install -U Django
def get_absolute_url(self):
from django.core.urlresolvers import reverse
return reverse('', kwargs={'pk': self.pk})
>>> one_entry = Entry.objects.get(pk=1)