hiii ..
i use REST api to get data from "https://www.football-data.org"; ..
i want to create one view that can restore any league (by league code like: 
PL for premier league) not for particular league
openleague.html
{% block content %}
<ul>
<li><a href="{% url 'core:openleague' PL %}">Premier League</a></li>
<li><a href="{% url 'core:openleague' PD %}">Spanish League</a></li>
<li><a href="{% url 'core:openleague' SA %}">Italian League</a></li>
<li><a href="{% url 'core:openleague' BL1 %}">German League</a></li>
<li><a href="{% url 'core:openleague' FL1 %}">French League</a></li>
</ul>
{% endblock %}
urls.py
urlpatterns =[
path('', views.home,name='home'),
path('<str:code>/League', views.openleague, name='openleague'),
]
views.py
def openleague(request,code):
connection = http.client.HTTPConnection('api.football-data.org')
headers = { 'X-Auth-Token': '72ae860eeabb435d9efef739f853b4fe' }
connection.request('GET', '/v2/competitions/{'code'}', None, headers)
response = json.loads(connection.getresponse().read().decode())

return render(request, 'core/openleague.html', {'response': response})

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f6801db1-7819-4dc5-899c-c306bee642d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to