I'm trying to send data to my database using Django Models and Views file but I'm continuously getting this error: "raise self.model.DoesNotExist( crm.models.Time_Stamps.DoesNotExist: Time_Stamps matching query does not exist."
I do have 'Time_Stamps' as a Model in models.py file.
How to resolve it?
views.py
def update_counter(request):
if request.method == 'POST':
timestamp = Time_Stamps.objects.get()
counterValue = request.POST['counter']
#timestamp.Task_ID = counterValue
timestamp.startTime = request.POST['timestamp']
print(counterValue)
print(startTime)
timestamp.save()
message = 'update successful'
return HttpResponse(message)
models.py
class Time_Stamps(models.Model):
TimeStamp = models.IntegerField(default=0)
def __str__(self):
return self.TimeStamp
class Meta:
verbose_name_plural = 'TimeStamps'
ERROR
......................
File "C:\Users\kushw\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\query.py", line 435, in get
raise self.model.DoesNotExist(
crm.models.Time_Stamps.DoesNotExist: Time_Stamps matching query does not exist.
[24/Sep/2021 15:44:27] "POST /update_counter/ HTTP/1.1" 500 73227