It's poorly written and mine isn't. Am I better than them. On Monday, December 5, 2022 at 6:36:30 AM UTC-8 [email protected] wrote:
> Good !😁 > > Le dim. 4 déc. 2022 à 22:04, Michael Starr <[email protected]> a > écrit : > >> Thank you, Peter. I forgot to acknowledge your contribution. >> >> On Wednesday, November 30, 2022 at 4:43:47 PM UTC-8 Ryan Nowakowski wrote: >> >>> On Wed, Nov 30, 2022 at 09:16:39AM -0800, Michael Starr wrote: >>> > Thank you. Though, that hard codes everything, which is bad. How do I >>> > generalize it? >>> >>> You'll need to do 2 things: >>> >>> 1. Add the pet(s) you want to the template context, probably by >>> implementing get_context_data[1]. >>> >>> 2. Change your template to use the pet from the template context instead >>> of the hard code pet, Mocha. Assuming your pet in the template context is >>> named 'pet': >>> >>> <a href="{% url 'pet_details' slug=pet.slug %}">Pet Profile: {{ pet.name >>> }}</a> >>> >>> ...alternatively since you've implemented get_absolute_url: >>> >>> <a href="{{ pet.get_absolute_url }}">Pet Profile: {{ pet.name }}</a> >>> >>> >>> [1] >>> https://docs.djangoproject.com/en/4.1/ref/class-based-views/mixins-simple/#django.views.generic.base.ContextMixin.get_context_data >>> >>> >> -- >> 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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c209ab85-1e49-47f0-a6a2-570b48f37021n%40googlegroups.com.

