{%for item in list%}
<a href="#" class="add-to-like"
data-id="{{ item.id }}"
{% if item in user.userprofile.liked_sentence.all %}
data-in_favorites="true"
{% else %}
data-in_favorites="false"
{% endif %}
data-type="sentence"
>
{% if item in user.userprofile.liked_sentence.all %}
<i class="fa fa-star gold" aria-hidden="true"></i>
{% else %}
<i class="fa fa-star default" aria-hidden="true"></i>
{% endif %}
</a>
{%endfor%}
def form_valid(self, form):
photos = self.request.POST.getlist('photos[]')
for strg in photos:
strg =strg.partition('base64,')[2]
img_data = base64_decode(strg)
photo = CompanyImage(order=self.object)
photo.file_up.save('123.jpg', ContentFile(img_data))
photo.save()
return HttpResponseRedirect(self.get_success_url())