J Lee
J Lee

Reputation: 1

how to send two parameters in url on django template language?

{% url 'start' commission.id applie.id %}

Like the above code, I am trying to send two model id but I don't know the right structure for it. and above code wouldn't work.

path('start/<int:post_id>', views.start, name="start"),

def start(request,post_id):

and also if i get two parenthesis, how should i modify the above url and view code?

Upvotes: 0

Views: 86

Answers (1)

Bhakti Raman Das
Bhakti Raman Das

Reputation: 37

Try to go with this way..

In urls.py--

path('profile/<name> <email>', views.profile, name='profile'),
#As path have space, it will take %20 there, 
#you can change it accordingly. best to use '-' instead of space
#http://example.com/profile/myname%[email protected]

In the link--

href="{% url 'profile' name='myname' email='[email protected]' %}"

In the views.py--

@login_required(login_url="login")
def profile(request, name, email):
   return render(request, "profile.html", {'name': name, 'email':email})

Upvotes: 1

Related Questions