Gene9y
Gene9y

Reputation: 859

In Django, pass parameters in href when a href uses the urlpattern not the url tag

I am trying to pass a parameter in a urlpattern not the url tag.

In urls.py,

   re_path(r'^send/(?P<uidb64>[0-9A-Za-z_\-]+)/$', views.send_email, name='send_email'),

In views.py,

   error_messages = { ...
        'inactive': _('<a href="/send/">Please get a new email</a>.'),
    }

I have to send a parameter in /send/ how can I set it up?

Upvotes: 0

Views: 40

Answers (1)

ruddra
ruddra

Reputation: 52028

You can try like this using reverse or reverse-lazy:

 error_messages = { ...
        'inactive': _('<a href="{}">Please get a new email</a>.'.format(reverse('send_email', args=[some_uuid]))),  # where some_uuid will have uuid for the url
    }

Upvotes: 1

Related Questions