Hi all,
I have created a website and for db am using remotely IBM Cloudant. So far I have learned Django locally using postgresql, mysql and sqlite (RDBMS), and for this time I am challenging myself with NoSQL db to expand my knowledge.
I have rendered some data in a table, used sentiment analysis to display reviews and there are other simple fundamental options to share feedback/review and registrations. Everything works fine except Bootstrap table that bugs.
However, I stuck with adding review_id in ReviewsView → reviews.html and cannot figure out how to add the id for quering the data by.
Here is the working code I have so far in ReviewsView in view.py:
class ReviewsView(TemplateView):
# model = no local db used
template_name = 'djangoapp/reviews.html'
# context_object_name =
# extra_context =
def get(self, request ): # <<--- review_id to use here
context = {}
dealer = get_dealers()['body']['rows']
review = get_reviews()['body']['rows']
if review is not None or review != "":
context['reviews'] = review
for i in context['reviews']:
value = i['doc'] # dict
# print(value)
conv = json.dumps(value)
# print(conv) # str
sentiment = analyze_review_sentiments(conv)
return render(request, "djangoapp/reviews.html", {"data": context['reviews'], "analyse": sentiment})
# From here I would like to create and make relation between Dealers column ID and Reviews column Dealership
for deal in dealer:
for dk, dv in deal['doc'].items():
if dk == "id":
dct_d.append(dv)
for rev in review:
for rk, rv in rev['doc'].items():
if rk == "dealership":
dct_r.append(rv)
# Tested to check matching IDs, but stuck with review_id
import numpy as np
test = np.intersect1d(dct_r, dct_d)
print(test)
return render(request, "djangoapp/reviews.html", {})
Here is the github repo: https://github.com/Kanatbek-AKA/django-CloudAppDevelopment_Capstone/tree/develop
I appreciate any advice and hint or even solution.
Kind regards,
Kanatbek