0

How the URL looks like

 http://<IP_ADDR>:<PORT>/api/post/<POST_NUMBER>

Here the POST_NUMBER is dynamic, how to send a request to the Page like this http://127.0.0.1:8080/api/post/14 Where 14 is the post number Here is my URL Pattern

path('api/post/<int>', views.PostView, name="Post")

Here is the PostView

def PostView(request,POST_NUMBER = 0):
       print(POST_NUMBER)

My error is PostView() got an unexpected keyword 'int'

1
  • You can try to write id instead of POST_NUMBER = 0. And then of course print the id Commented Sep 19, 2019 at 7:24

1 Answer 1

1

try this

in urls

path('api/post/<post_number>', views.PostView, name="Post") 
or 
path('api/post/<int:post_number>', views.PostView, name="Post")

in views

def PostView(request,post_number = 0):
       print(post_number)

refer this

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.