Wednesday, November 30, 2022

Re: URL evaluates to 'slug' literally instead of the variable slug

On Tue, Nov 29, 2022 at 06:35:25PM -0800, Michael Starr wrote:
> *home folder / home.html*
> <!DOCTYPE html>
> <html lang="en" dir="ltr">
> <head>
> <meta charset="utf-8">
> <title></title>
> </head>
> <body>
> test
> <a href="{% url 'pet_details' slug='slug' %}">Pet Profile: Mocha</a>
> </body>
> </html>

In your home.html you've hard coded a link to a specific pet named Mocha.
You'll need to hard code the slug as well so:

<a href="{% url 'pet_details' slug='mocha' %}">Pet Profile: Mocha</a>

--
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/20221130151510.GC8954%40fattuba.com.

No comments:

Post a Comment