0

I have a task in which in have to create view.py, template, url.py and model.py in django, In which I have four Button D1, D2, D3, D4 in template.
When I click on D1 it should redirect me to a page whose link is: http://127.0.0.1:8000/uploads/test/**D1**

And while clicking on D2 link redirects me one same page and link is http://127.0.0.1:8000/uploads/test/**D2**

Similarly while clicking on D2 and D3 links are
http://127.0.0.1:8000/uploads/test/**D3** and http://127.0.0.1:8000/uploads/test/**D4**

BATMAN
  • 375
  • 2
  • 14
  • 2
    Does this answer your question? [How do I pass parameters via url in django?](https://stackoverflow.com/questions/32567808/how-do-i-pass-parameters-via-url-in-django) – funie200 Jan 20 '20 at 10:39

1 Answers1

2

You can pass parameters in Django URLs like this

path('test/<int:post_id>',views.index, name='index'),

Here post_id is the parameter you can use yours.

<int:> is for integers and <str:> is for strings

Mohit Chandel
  • 1,838
  • 10
  • 31
  • Also, You can accept the same variable in your view along with your request parameter as: `SomeViewName(request, post_id):` – BATMAN Jan 22 '20 at 05:23