thank you Derek it works
now i read documentation
do you have any advice ?

On Sunday, July 7, 2019 at 10:18:56 AM UTC+2, Derek wrote:
>
> Have you tried without the {'code'}
>
> As per their example:
>
> [image: api1.png]
>
>
> On Thursday, 4 July 2019 23:42:05 UTC+2, omar ahmed wrote:
>>
>> 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': '##################' }
>> 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/eea36f57-cf13-4e83-9589-f54b80b347d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to