I’m trying to retrieve a list of tags that share the same name as a django Country. (i will be throwing it into my autocomplete search). What I have isn’t working:
View:
from django_countries.countries import COUNTRIES
...
@login_required
def country_tags(request):
result = {}
tags = Tags.objects.all()
countries = list(COUNTRIES)
for tag in tags:
for country in countries:
if country.name == tag.name:
result[tag.name] = tag.name.title()
return HttpResponse(json.dumps(result))
Can’t quite figure out why this isn’t working. Am I wrong to reference country.name?
Here is a version that should work.
COUNTRIESis a 2-tuple tuple.