Whenever I try to print the dictionaries in Django I can't get what I need. The views models are given below. Geeks help to solve this beginner question
Views.py
def home(request):
roomCate=dict(Room_Type.ROOM_CATEGORIES)
roomUrl=Room_Type.objects.all()
print(roomCate)
print(roomUrl)
Whenever I print roomCate and roomUrl, I got what I need in roomUrl but, in roomCate I changing while printing the dictionaries of value, <QuerySet [<Room_Type: Sig>, <Room_Type: Lux>, <Room_Type: Elt>]> The value is not changing while print the value
But in {'Lux': 'Luxury', 'Sig': 'Signature', 'Elt': 'Elite'} the value is changing.
Here is my models.py
class Room_Type(models.Model):
"""Django data model Room_Type"""
ROOM_CATEGORIES={
('Elt','Elite'),
('Lux','Luxury'),
('Sig','Signature')
}
image = models.ImageField(upload_to="pics")
roomtype = models.CharField(choices=ROOM_CATEGORIES,max_length=20)
price = models.CharField(blank=True, max_length=100)
def __str__(self):
return f'{self.roomtype}'
I want the method print result same as roomUrl but I can't get the value same as roomUrl. Please geeks help me solve this
Thank You
return render(request,'index.html')