help on what to query message display view template

i am trying to do user to user message app and i cam across this postman package to help
but it has regex urls patterns that i really didn’t like to use or see in my patterns, but i like to try and learn

    re_path(pgettext_lazy('postman_url', r'^view/(?P<message_id>[\d]+)/$'), MessageView.as_view(), name='view'),

here is the view class that is responsible for view the specified message

class MessageView(DisplayMixin, TemplateView):
    """Display one specific message."""
    def get(self, request, message_id, *args, **kwargs):
        self.filter = Q(pk=message_id)
        return super().get(request, *args, **kwargs)

when i try to go to this page using this url in template

<a href="{% url 'postman:view' message.id %}" class="boxed-btn3 w-20">View Message</a>

i got this error


i have tried a lot of different options as message.id or .pk or message_id and all didn’t work
what should i put there to get this view specially when i have another urls that will need the same id or other options

    re_path(pgettext_lazy('postman_url', r'^trash/(?:(?P<option>m)/)?$'), TrashView.as_view(), name='trash'),
    re_path(pgettext_lazy('postman_url', r'^write/(?:(?P<recipients>[^/#]+)/)?$'), WriteView.as_view(), name='write'),
    re_path(pgettext_lazy('postman_url', r'^reply/(?P<message_id>[\d]+)/$'), ReplyView.as_view(), name='reply'),
    re_path(pgettext_lazy('postman_url', r'^view/(?P<message_id>[\d]+)/$'), MessageView.as_view(), name='view'),

any idea what should i put in case of message.id, and the others option or for specified message

Specifically, the error is caused by:

for whatever reason, you either aren’t passing a message object in to your template through the context or the message object doesn’t have an attribute named id.

Review the docs at Base views | Django documentation | Django - you want to ensure that all the data that needs to be rendered in the template is added to the context.

the message model doesn’t have any id field and here is the get_absolute_url() function

class Message(models.Model):
    """
    A message between a User and another User or an AnonymousUser.
    """
    subject = models.CharField(_("subject"), max_length=SUBJECT_MAX_LENGTH)
    body = models.TextField(_("body"), blank=True)
    sender = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='sent_messages',
        null=True, blank=True, verbose_name=_("sender"))
    ...
    class Meta:
        verbose_name = _("message")
        verbose_name_plural = _("messages")
        ordering = ['-sent_at', '-id']
    def get_absolute_url(self):
        "Usage is deprecated since v3.3.0, because it doesn't integrate well with the addition of namespaces."
        return reverse('postman:view', args=[self.pk])

i have used pk but the creator of the model mentioned in the function doctext that

it doesn’t integrate well with the addition of namespaces.
forgive me on my dummy knowledge in class based view, cause i want to review all of it and i am really forgetful person.
so i am really confused what how to get the message object in this class based view in the context
i will try to read more brother, anyway but really i hope you are fine always and safe and wish to you all the best and welfare and healthy life, you always been so helpful nice person, thanks from my deep heart.
and if you have an idea or want me to send anything else tell me.

See: Models | Django documentation | Django

When trying to really understand how CBVs work, I recommend people see the Classy Class-Based Views site along with the CBV diagrams page. They both help me a lot with understanding how they work and what each function does.

appreciated bro and i will back to you after all