I am looking to create a portfolio using Django. I have tried using ImageField but it only allows me to upload and replace 1 photo.
I am new to Python and Django programming. How would I create a model to upload multiple images and show them in a gallery? Thanks.
You can try django-galleryfield. BTW, I am the author of the package.
Just put the following code in your gallery template.
{% for image in images %}
{% if forloop.first %}
<div class="row ">
{% endif %}
<div class="col-lg-4 col-md-4 col-12" >
<div class="text-center mt-2">
<img src="{{image.image.url}}"height="70%" width="70%" class="img-thumbnail" alt="...">
</div>
</div>
{% if forloop.counter|divisibleby:3 %}
</div>
<div class=row>
{% endif %}
{% if forloop.last %}
</div>
{% endif %}
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With