def bands_by_label(request, label): bands = Band.objects.filter(current_label__icontains=label) bands_list = [] for band in bands: bands_list.append(convert_band_to_dict(band)) return HttpResponse(json.dumps(bands_list), content_type="application/json")
def bands_by_genre(request, genre): bands = Band.objects.filter(genre__icontains=genre) bands_list = [] for band in bands: bands_list.append(convert_band_to_dict(band)) return HttpResponse(json.dumps(bands_list), content_type="application/json")
def bands_by_year(request, year): bands = Band.objects.filter(formation_year=year) bands_list = [] for band in bands: bands_list.append(convert_band_to_dict(band)) return HttpResponse(json.dumps(bands_list), content_type="application/json")
def bands_by_lyrical_themes(request, lyrical_themes): bands = Band.objects.filter(lyrical_themes__icontains=lyrical_themes) bands_list = [] for band in bands: bands_list.append(convert_band_to_dict(band)) return HttpResponse(json.dumps(bands_list), content_type="application/json")
def bands_by_status(request, status): bands = Band.objects.filter(status__iexact=status) bands_list = [] for band in bands: bands_list.append(convert_band_to_dict(band)) return HttpResponse(json.dumps(bands_list), content_type="application/json")
def bands_by_id(request, band_id): bands = Band.objects.filter(ma_id=band_id) bands_list = [] for band in bands: bands_list.append(convert_band_to_dict(band)) return HttpResponse(json.dumps(bands_list), content_type="application/json")
def bands_by_musician(request, musician): bands_list = [] musicians = BandMusician.objects.get_queryset() for musician in musicians.filter(name__icontains=musician): musicians_band = musician.lineup.band if musicians_band not in bands_list: bands_list.append(convert_band_to_dict(musicians_band)) return HttpResponse(json.dumps(bands_list), content_type="application/json")
def bands_similar_to(request, band_id): original_band = Band.objects.get(ma_id=band_id) bands_list = [] for similar_band in original_band.similarartist_set.all(): band = Band.objects.filter(ma_id=similar_band.ma_id).first() if band: band_dict = convert_band_to_dict(band) bands_list.append(band_dict) return HttpResponse(json.dumps(bands_list), content_type="application/json")