How to get One object value from database in Django
The situation is I have a table named Status consists of two fields. one is id which is primary key and based on auto increment and second is status which is integer. Now, the scenario is that I only want to get the value of status not id. Here are the details:
views.py:
from cvs.models import status_mod
field_object = status_mod.objects.get(status)
print(field_object)
models.py:
class status_mod(models.Model):
id = models.BigIntegerField
status = models.BigIntegerField
class Meta:
db_table = "status"
The issue is that I want to store status value in a variable and want to call him in my template. Any solvable solution please
you need to specify the status value you want
field_object = status_mod.objects.get(status=1)
django already creates the id field by default, you don't need to create it