I am trying to write a class-based view which will take two inputs, say "city" and "bankname," and filter the data and send the results.
I am trying to write:
http://127.0.0.1:8000/api/bankcitydetail?city=mumbai&bankname=CENTRAL BANK OF INDIA.
How would I write the URL's path in urls.py?
from django.urls import path
from . import views
urlpatterns = [
path('', views.x)
]
x = Whatever your function is
I am not sure why you included the bankcitydetail
in your url, you could just use:
http://127.0.0.1:8000/api/?city=mumbai&bankname=CENTRAL BANK OF INDIA
That would be something like this:
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('api/', views.api, name='api'),
]
If you want to use the bankcitydetail
to specify the resource in the API, you could use path converters like in the example in Django'sdocumentation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.