So I am making a website using Django, HTML/CSS, and Bootstrap 5 to display books a user has. Currently, all the books are displayed in one row but I would like them to be split up into multiple rows with three on each row. How should I go about doing this?
This is the model I'm using for the book:
lass Book(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
isbn = models.CharField('ISBN', max_length=16, unique=True,
help_text='10 Character <a href="https://www.isbn-international.org/content/what-isbn">ISBN number</a>')
title = models.CharField(max_length=10, null=True, blank=True)
image_src = models.CharField(max_length=400, null=True, blank=True)
author = models.CharField(max_length=50, null=True, blank=True)
desc = models.CharField(max_length=1000, null=True, blank=True)
LOAN_STATUS = (
('AVAILABLE', 'Available'),
('ON LOAN', 'On Loan'),
('ON HOLD', 'On Hold'),
)
GENRES = {
('REALISTIC FICTION', 'Realistic Fiction'),
('HISTORICAL FICTION', 'Historical Fiction'),
('SCIENCE FICTION', 'Science Fiction'),
('ADVENTURE', 'Adventure'),
('FANTASY', 'Fantasy'),
('HORROR', 'Horror'),
('MYSTERY', 'Mystery'),
('NON-FICTION', 'Nonfiction'),
}
genre = models.CharField(
max_length=30,
choices=GENRES,
blank=True,
help_text='Book Genre',
)
status = models.CharField(
max_length=30,
choices=LOAN_STATUS,
blank=True,
default='Available',
help_text='Book Availabiliy',
)
def __str__(self):
#String representing model object
return self.title
And this is the HTML for the book list page:
{% extends "base_generic.html" %}
{% block content %}
<div class="d-flex justify-content-around pt-4">
{% for book in object_list %}
<div><a href="{% url 'book_detail' book.pk %}">
<img src={{book.image_src}}>
<p class="text-center"><strong>{{ book.title }}</strong></p>
</div></a>
{% empty %}
<p>No books in your catalog.</p>
{% endfor %}
</div>
{% endblock %}
Thanks so much! I'm a beginner in web dev so sorry if this is a simple fix. :)