I am trying to build a simple search function on django that leads me to the link when I click on it. (I know API links are JSON links so clicking on them gives you no output of value but the point is to be able to click on them)
i tried using but it doesn't work
from my results.html:
{% for dataset in datasets %}
<br/>
{{ dataset.datasets_available }}
<br/>
{{ dataset.data_source }}
<br/>
{{ dataset.brief_description_of_datasets }}
<br/>
{{ dataset.country }}
<br/>
<a href='https://www.google.com'>{{ dataset.api_documentation }}<a>
<br/> #^ is the part i wanna fix
<br/>
{% endfor %}
{% else %}
<p style="font-family:Cambria">No search results for this query</p>
{% endif %}`
from views.py:
def results(request):
query = request.GET.get('q')
if query:
datasets = api_data.objects.filter(Q(datasets_available__icontains=query))
context = {
'datasets': datasets,
}
return render(request, 'Search/results.html', context)
from models.py:
class api_data(models.Model):
data_source = models.TextField()
brief_description_of_data = models.TextField()
datasets_available = models.TextField()
brief_description_of_datasets = models.TextField()
country = models.TextField()
api_documentation = models.TextField()
class Meta:
verbose_name_plural = "api_data"
api_documentation is currently urls in strings. i want to be able to click on the output in html and view the actual website