100909/i-can-t-get-accurate-value-in-dictionaries-in-django
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')
Hey, @Mohamed,
Are you facing any error while executing your code? If you facing any code do post it here so that we can resolve this ASAP.
The optimal CutOff value is the point ...READ MORE
Hii Kartik,
check uwsgi + django source code and pass static param ...READ MORE
Hello @kartik,
You can use request.headers to access the HTTP ...READ MORE
Hello @kartik,
Using a form in a view can ...READ MORE
Hello @kartik,
You can use the request object ..
OR
Already have an account? Sign in.