Wednesday, November 30, 2022

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

Thank you. Though, that hard codes everything, which is bad. How do I
generalize it?

Also, this worked. I had to specify template_name = pet_profile.html in
the pet detail view.


On 11/30/22 7:15 AM, Ryan Nowakowski wrote:
> 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/4f4f2184-48c9-5448-2fe2-a1ae5550a89c%40spinningcow.xyz.

No comments:

Post a Comment