i need to show multiselectfields

101 views
Skip to first unread message

Gegi Esitashvili

unread,
May 16, 2021, 11:20:37 AM5/16/21
to Django users
hello everyone, i am using django allauth, also i have installed multiselectfield and trying show my facilities on the site.

this is my models.py

class Hotel(models.Model):
name = models.CharField(max_length=128)
description = models.TextField()
stars = models.IntegerField()
price = models.IntegerField()
picture = models.ImageField(upload_to='images', default="images/124180566_3771168516249284_3976912378791517206_o.jpg")
HOTEL_TYPE = (
("Free WiFi", "free wiFi"),
("Free Parking", "Free Parking"),
)
popular_facilities = MultiSelectField(choices=HOTEL_TYPE)


this is my views.py 

def see_more(request, id):
seemore = Hotel.objects.get(id=id)
reviews = HotelReview.objects.filter(review=id, permission=True)[:2]
facilities = seemore.popular_facilities
form = HotelReviewForm()
if request.method == "GET":
form = HotelReviewForm(request.GET or None) #request.FILES მედიას ატვირთვა თუ გვინდა
if form.is_valid():
data = form.save(commit=False)
data.review = seemore
data.name = form.cleaned_data.get("name")
data.email = form.cleaned_data.get('email')
data.comment = form.cleaned_data.get('comment')
data.rating_number = form.cleaned_data.get('rating_number')
data.permission = True
data.save()

return redirect('hotel:seemore', id)

context = {
'seemore':seemore,
'reviews':reviews,
'form':form,
'facilities':facilities
}
return render(request, 'hotel/seemore.html', context)

and this is my html

<p class="se-p">Popular Facilities</p>
<ul>
{% for facilitie in facilities %}
<li class="fac"><i class="fas fa-swimmer iconsize"></i>{{ facilitie }}</li>
{% endfor %}

and this is what is showed up1.PNG



can anyone help me?

RANGA BHARATH JINKA

unread,
May 17, 2021, 12:21:25 AM5/17/21
to django...@googlegroups.com
Hi,

Use a select box with multiple attribute instead of ul and li. Loop through options. Please go through this. https://www.w3schools.com/tags/att_select_multiple.asp#:~:text=For%20windows%3A%20Hold%20down%20the,button%20to%20select%20multiple%20options

All the best 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/db5fa916-7676-4ba8-bea0-05f4e0f8af8cn%40googlegroups.com.


--
Thanks and Regards

J. Ranga Bharath
cell: 9110334114

Gegi Esitashvili

unread,
May 18, 2021, 10:34:47 AM5/18/21
to Django users
I may have misinterpreted what I wanted and you misunderstood. I specify 'specific options' from the admin panel, then one of the pages should display the specific option I chose in the admin panel
What you told me is about the html page and not django :(

Gegi Esitashvili

unread,
May 18, 2021, 10:35:01 AM5/18/21
to Django users

and i got it what i wanted but it is only facilitiess id and not its name, so i need to show up its name and not id.
On Monday, 17 May 2021 at 08:21:25 UTC+4 bharath...@gmail.com wrote:

RANGA BHARATH JINKA

unread,
May 18, 2021, 10:58:52 AM5/18/21
to django...@googlegroups.com
Hi,

Please share screenshots. So that we can understand where you want to show

RANGA BHARATH JINKA

unread,
May 18, 2021, 11:11:11 AM5/18/21
to django...@googlegroups.com
use {{ facilitie.name }} instead of {{ facilitie }}
<li class="fac"><i class="fas fa-swimmer iconsize"></i>{{ facilitie.name }}</li>

Gegi Esitashvili

unread,
May 18, 2021, 12:47:24 PM5/18/21
to django...@googlegroups.com
I tried it before posted here, It doesnt work unfortuntly :(

You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/XkHCuUnLsoQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK5m316DHEKv954tZ2atwEOdPGK6WMquRqvGHnwW3ByK6PJY-A%40mail.gmail.com.
--
Sincerely

Gegi Esitashvili

RANGA BHARATH JINKA

unread,
May 18, 2021, 1:28:41 PM5/18/21
to django...@googlegroups.com
What is the error you are facing. Please share the screenshots

Gegi Esitashvili

unread,
May 18, 2021, 3:48:16 PM5/18/21
to Django users
there is no error, just removing id numbers

1.PNG

Reply all
Reply to author
Forward
0 new messages