Django-bootstrap4 page rendering problem!

I have started to learn Django framework and I am using Python Crash Course by Eric Matthes as a reference book. I wanted to make sth slightly different than what the book shows but also I have been following mainly the book’s steps. I am trying to make a web site where users can register their board games and borrow them.

I am having a problem when I want to make a user return a board game. I created a form and assign a button that would call the return function. But the page cannot be rendered and here is the error I get. screencapture-127-0-0-1-8000-my-loans-2022-12-23-09_52_15.png - Google Drive I believe the page isn’t being rendered because I am using the form inside the loop and for some reason return_loan doesn’t get a proper loan.id

I have also tried to take my form outside the loop and assign buttons, this time the page was rendered but I couldn’t make the buttons get dynamically the proper id for the loan that would be returned.

Here are the requirements for my django project:

asgiref==3.5.2
beautifulsoup4==4.11.1
Django==4.1.4
django-bootstrap4==22.3
soupsieve==2.3.2.post1
sqlparse==0.4.3

My views.py : views.py - Pastebin.com

My urls.py : urls.py - Pastebin.com

my_loans.html: my_loans.html - Pastebin.com

my_loans.html: my_loans_form_outside_loop.html - Pastebin.com - Here the page is rendered but I couldn’t find a way to get dynamically an id for my loan.

Here is also my github repository for my project. GitHub - urasayanoglu/board_game_club: A web application for loaning board games built in django framework
I haven’t committed and pushed the changes I share above with the pastebin links. So those are not in the repostitory yet.

I’ have been reading the documentation about forms for integrating the bootstrap 4 for django (Welcome to django-bootstrap4’s documentation! — django-bootstrap4 22.3 documentation) and also django documentation for forms but I couldn’t get the solution by myself.

I’d appreciate if you guys could guide me to the right direction.

Thanks in advance,

Uras

First, a side note: In the future, please post your code and traceback in the body of your post rather than references to external sites. When posting code (or templates, tracebacks, etc), surround them between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code (etc), then another line of ```. Also, for the traceback, you can copy/paste the traceback from the console where you’re running runserver rather than the error page rendered in the browser.

Now, on to the core of the issue you’re reporting here, the fundamental cause of the issue is that you’re trying to render a URL (return_loan) with a parameter ("{% url 'board_game_club_apps:return_loan' loan.id %}"), but the url is defined without having a parameter defined ( path('return_loan', views.return_loan, name="return_loan"),).

Thanks for the quick response Ken, I really appreciate it. Your advice worked like charm. Thank you so much and sorry for my ignorance.

You’re certainly welcome, and there’s never a need to apologize for your current lack of knowledge. We’re here specifically to help you get past that.