new record is created while updating

41 views
Skip to first unread message

Ayush Bajpai

unread,
Jun 23, 2022, 10:06:36 AM6/23/22
to Django users
model:
class Batch(models.Model):
    batch_id = models.AutoField(primary_key=True, default=None)
    batch_name = models.CharField(max_length=256, default=None, null=True)
    ... some more fields

views:
def organisationEditBatch(request, batch_id):
    batch = Batch.objects.get(batch_id=batch_id)
    if request.method == 'POST':
        batch.batch_name = request.POST.get("batch_name")
        batch.save() 

Ayush Bajpai

unread,
Jun 24, 2022, 4:31:58 AM6/24/22
to Django users
    raise self.model.DoesNotExist(
apps.courseApp.models.Batch.DoesNotExist: Batch matching query does not exist.

actually this is the error it is giving but i do have a batch_id.., when i prefill the data of particular batch_id in edit form it gets displayed corretly there. but here it gives this error. i don't understand this issue so pls if anyone could help, i need it urgently!!
Reply all
Reply to author
Forward
0 new messages