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
On Sun, May 16, 2021 at 8:50 PM Gegi Esitashvili <gegiesitashvili@gmail.com> wrote:
hello everyone, i am using django allauth, also i have installed multiselectfield and trying show my facilities on the site.this is my models.pyclass 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.pydef 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 %}can anyone help me?--
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+unsubscribe@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
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK5m3153HatNisk_aLZKjSXuRffhHAe2%3DT1%3D7ahE-ps%3D8E86PA%40mail.gmail.com.
No comments:
Post a Comment