Skip to content

Commit

Permalink
Added Link to API
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliia Hladyshkevych committed Jan 25, 2024
1 parent 669664a commit 6bebe60
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cryptocurrency/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.shortcuts import get_object_or_404
from rest_framework.generics import ListAPIView, RetrieveAPIView
from rest_framework.mixins import ListModelMixin
from rest_framework.pagination import PageNumberPagination
from rest_framework.renderers import TemplateHTMLRenderer
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet

from cryptocurrency.models import Cryptocurrency
from cryptocurrency.serializers import CryptocurrencyListSerializer
Expand All @@ -14,6 +16,11 @@ class CryptocurrencyPagination(PageNumberPagination):
max_page_size = 100


class CryptocurrencyViewSet(ListModelMixin, GenericViewSet):
serializer_class = CryptocurrencyListSerializer
queryset = Cryptocurrency.objects.all()


class CryptocurrencyListView(ListAPIView):
serializer_class = CryptocurrencyListSerializer
renderer_classes = [TemplateHTMLRenderer]
Expand Down
1 change: 1 addition & 0 deletions cryptocurrency_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
"cryptocurrencies/",
include("cryptocurrency.urls", namespace="cryptocurrency"),
),
path("api/", include("cryptocurrency.urls_api", namespace="api")),
]
11 changes: 11 additions & 0 deletions static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ body {
background-color: lightgray;
}

a {
transition: color 0.3s ease;
color: #333;
margin-left: 20px;
text-align: center;
}

a:hover {
color: #0056b3;
}

h1 {
color: #333;
margin-left: 20px;
Expand Down
3 changes: 3 additions & 0 deletions templates/cryptocurrency/cryptocurrency_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{% block content %}
<h1>Crypto Market Insights</h1>
<p>Welcome to Crypto Django API!</p>
<h1 class="list-group-item"><a
href="{% url "api:cryptocurrency-list-api" %}">Link to API</a></h1>


<div id="app">
<table class="table table-hover">
Expand Down

0 comments on commit 6bebe60

Please sign in to comment.