Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
i am fetching data from database and i am getting in column manner. but i want to get this in column and rows using python
exam_table = Examination.objects.all() json_data = serializers.serialize('json',exam_table) pdict = json.loads(json_data) #print(pdict) sub_list=[] exam_start_time=[] exam_stop_time=[] for obj in pdict: sub_list.append(obj['fields']['Subjects']) exam_start_time.append(obj['fields']['exam_start_time']) exam_stop_time.append(obj['fields']['exam_stop_time']) json_data = json.dumps(sub_list) pdict = json.loads(json_data) pdict1 = list(pdict) #print(pdict1) json_data_st = json.dumps(exam_start_time) pdict_st = json.loads(json_data_st) pdict_st1 = list(pdict_st) #print(pdict_st1) json_data_stop = json.dumps(exam_stop_time) pdict_stop = json.loads(json_data_stop) pdict_stop1 = list(pdict_stop) The above is my code this is what i am getting a output Subject is sasasasasas Subject is Subject is Subject is Subject is Subject is Subject is Subject is Subject is sasasasasas Subject is Subject is Subject is Subject is Subject is Subject is Subject is Subject is subject1 Subject is subject2 Subject is subject3 Subject is subject4 Subject is subject5 Subject is Subject is Subject is -
How to use oak coin in python projects
I want to use the oak coin in my project. I have used python3 with Django. I want to generate oak coin and display all oak coins with all related data. -
django No Reverse Match from different model
I am working on a project when something spit the following error: Reverse for 'project-file-delete' with arguments '('',)' not found. 1 pattern(s) tried: ['projects/(?P<pk>[0-9]+)/project\\-file/delete/$'] here is my main urlpattern: urlpatterns = [ path('', welcome_view.home, name='welcome'), path('projects/', include('projects.urls'))] my project app's urlpattern: urlpatterns = [ path('', ProjectListView.as_view(), name='project-home'), path('user_project/<str:username>/', UserProjectListView.as_view(), name='user-projects'), path('<int:pk>/', ProjectDetailView.as_view(), name='project-detail'), path('new/', ProjectCreateView.as_view(), name='project-create'), path('<int:pk>/update/', ProjectUpdateView.as_view(), name='project-update'), path('<int:pk>/delete/', ProjectDeleteView.as_view(), name='project-delete'), path('<int:pk>/create_base_file/', ProjectFileCreateView.as_view(), name='project-base-file'), path('<int:pk>/project-file/delete/', ProjectFileDeleteView.as_view(), name='project-file-delete'), path('<int:pk>/project_file/', views.proj_file_detail, name='project-file-detail'), ] my project's model class definition: class Project(models.Model): name = models.CharField(max_length=100) description = models.TextField() date_created = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return self.name def get_absolute_url(self): return reverse('project-detail', kwargs={'pk': self.pk}) class ProjectFile(models.Model): FILE_TYPE = ( ('base', 'Base File'), ('transformed', 'Transformed File'), ('discretized', 'Discretized File'), ('model', 'Model File') ) file = models.FileField(upload_to='project-files', default=True) category = models.CharField(max_length = 50, default = 'base', choices = FILE_TYPE) description = models.TextField(default = 'base file') project = models.ForeignKey(Project, on_delete=models.CASCADE) def __str__(self): return self.description def get_absolute_url(self): return reverse('project-detail', kwargs = {'pk': self.project}) #kwargs={ 'project': self.project }) and finally my Project File Delete View: class ProjectFileDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView): model = Project template_name = 'projects/project_file_confirm_delete.html' # template for deletion success_url ='/projects/' # url after successfull deletion # Test user permission def test_func(self): project = self.get_object() if self.request.user … -
What are Hyperlinked APIs in Django rest framewrok?
What exactly is hyperlinked APIs or hyperlinked fields in Django models. What scenarios or what sort of data do we save in hyperlinked fields? What are the use cases and cost of using this? -
How to display list of same values as one values in django?
Imagine there are two types of tastes such as "bad", "Good" Fruit | Taste -------------- Mango | Good Apple | bad Mango | Good My goal is to display: Fuit | Taste Count ------------------ Mango | 2 Apple | 1 -
Need help ModelMultipleChoiceField error in Django
I am using a ModelMultipleChoiceField to do something but I am getting an error saying: AttributeError at /auth_users/ 'MultipleChoiceField' object has no attribute 'all' My form is: class AuthUserCheckbox(forms.Form): choice = forms.ModelMultipleChoiceField(queryset=User.objects.none(), widget=forms.CheckboxSelectMultiple, required=True) def __init__(self, *args, **kwargs): self.user = kwargs.pop('user') user_email = self.user.email.split('@')[1] super(AuthUserCheckbox, self).__init__(*args, **kwargs) self.fields['choice'].queryset = forms.MultipleChoiceField( choices=[ (i.email, i.email) for i in User.objects.filter( is_active=False, email__icontains=user_email ) ] ) My view is: @login_required def auth_users(request): if request.method == 'POST': form = AuthUserCheckbox(request.POST, user=request.user) if form.is_valid(): AuthUserCheckbox.auth_users(form) return render(request, 'todoapp/success.html') else: return HttpResponse('<h3>Authorization failed</h3>') return render(request, 'todoapp/auth_users.html', context={'form': AuthUserCheckbox(user=request.user)}) Where am I going wrong ? this error has been bugging me a lot. -
How to check data available or not in table using django query?
We have one table and using django orm query we have to check that data is available or not in table. So my question is using orm query and if,else conditions we have to show. -
Pagination Elasticsearch in Django
I am a newbie in Elasticsearch, I just try to create a search engine using it in Django. Overall, the engine shows good results. Unfortunately, it loads a large number of the results. Then, I try to paginate it by regular pagination in Django, after that, the page load error object of type 'Search' has no len(). These are my codes: view.py from django.shortcuts import render, redirect from elasticsearch import Elasticsearch from elasticsearch_dsl import Search from django.core.paginator import Paginator def search_es(request): return render(request,'search/search.html') def results(request): s = Search(using=Elasticsearch()) keyword = request.GET.get('q') # keyword that want to be found print(keyword) if keyword: # posts = s.query('match_phrase_prefix',head_title=keyword) # if posts.count() == 0: posts = s.query( "multi_match", query=keyword, fields=['head_title^5', 'description^5', 'description.ngram'], # type="phrase_prefix", ) posts = posts[0: 100] else: posts = '' page = request.GET.get('page', 1) paginator = Paginator(posts, 10) try: users = paginator.page(page) except PageNotAnInteger: users = paginator.page(1) except EmptyPage: users = paginator.page(paginator.num_pages) context = { 'page_title': keyword, 'posts': users, 'count': posts.count(), 'keyword': keyword, } return render(request,'search/results.html',context) results.html {% if posts.has_other_pages %} <ul class="pagination"> {% if posts.has_previous %} <li><a href="?page={{ users.previous_page_number }}">«</a></li> {% else %} <li class="disabled"><span>«</span></li> {% endif %} {% for i in posts.paginator.page_range %} {% if posts.number == i %} … -
i got an error saying category matching query does not exists while redirecting after voting
DoesNotExist at /rank/annapurna-circuit-trek/ Category matching query does not exist. Request Method: GET Request URL: http://127.0.0.1:8000/rank/annapurna-circuit-trek/ Django Version: 2.1.5 Exception Type: DoesNotExist Exception Value:Category matching query does not exist. Exception Location: C:\Users\Lenovo\AppData\Local\Programs\Python C:\Users\Lenovo\Desktop\Django_Projects\TheRanker\rank\views.py in options category = Category.objects.get(slug=slug) models.py class Category(models.Model): name = models.CharField(max_length=250) slug = AutoSlugField(populate_from='name') details = models.TextField(blank=True) image = models.ImageField(blank=True,upload_to='categories') views = models.IntegerField(default=0) created = models.DateTimeField(auto_now=True) modified = models.DateTimeField(auto_now_add=True) active = models.BooleanField(default=True) def __str__(self): return self.name class Meta: verbose_name_plural = "Categories" class Option(models.Model): name = models.CharField(max_length=250) slug = AutoSlugField(populate_from='name') image = models.ImageField(blank=True,upload_to='options') details = models.TextField() category = models.ForeignKey(Category, on_delete=CASCADE) votes = models.IntegerField(default=0) active = models.BooleanField(default=True) def __str__(self): return self.name class Vote(models.Model): option = models.ForeignKey(Option, on_delete=CASCADE) voter = models.ForeignKey(User, on_delete=CASCADE) slug = AutoSlugField(populate_from='option') def __str__(self): return self.voter urls.py from django.urls import path from rank import views app_name = 'rank' urlpatterns = [ path('',views.home,name='home'), path('register/',views.registration,name='register'), path('login/',views.my_login,name='login'), path('logout/',views.my_logout,name='logout'), path('<slug>/',views.options,name='options'), path('<slug>/vote/', views.vote, name='vote'), ] views.py def home(request): categories = Category.objects.filter(active=True) return render(request,'rank/base.html',{'categories': categories,'title':'TheRanker'}) def options(request,slug): category = Category.objects.get(slug=slug) options = Option.objects.filter(category=category) return render(request,'rank/options.html',{'options':options,'title':'options'}) def vote(request,slug): option = Option.objects.get(slug=slug) if Vote.objects.filter(slug=slug,voter_id=request.user.id).exists(): messages.error(request,'You Already Voted!') return redirect('rank:options',slug) else: option.votes += 1 option.save() voter = Vote(voter=request.user,option=option) voter.save() messages.success(request,'Voted!') return redirect('rank:options',slug) def registration(request): if request.method == "POST": form = RegisterForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.save() … -
Django ModelForm input fields from Model doesn't show
So I'm just getting started with django and am trying to implement a ModelForm. However something goes wrong, the input fields from the model doesnt appeare in the HTML, but the submit-button which is implemented in the HTML does. I would appriciate it if anyone could tell me where I do wrong or can refer me to a source that would help me out. form.py from .models import Article from django import forms class Article_form(forms.ModelForm): class Meta: model = Article fields = [ 'title', 'content' ] models.py from django.db import models # Create your models here. class Article(models.Model): title = models.CharField(max_length = 120) content = models.TextField(max_length = None) views.py from django.shortcuts import render from .forms import Article_form from .models import Article # Create your views here. def create_article(request): form = Article_form(request.POST or None) if form.is_valid(): form.save() form = Article_form() context = { 'form': form } return render(request, "articles/form.html", context) form.html <form method="POST">{% csrf_token %} {{ form.as_p }} <input type="submit" value="OK"> </form> index.html <html> <body> <h2>This is a page</h2> {% include 'articles/form.html' %} </body> </html> If you need any other information please tell me! Thank you! -
filtering multiple models having a DateRange field as "validity_range"
Using the Django ORM, I have multiple models (A, B, A2B) who all inherit from a ValidityMixinModel that represents their validity period. class ValidityMixinModel(models.Model): validity_range = DateRangeField(null=True, blank=True) class Meta: abstract = True class A(ValidityMixinModel): Bs = models.ManyToManyField("B", through="A2B") class B(ValidityMixinModel): As = models.ManyToManyField(A, through="A2B") class A2B(ValidityMixinModel): a = models.ForeignKey(A, related_name="Bs_through", on_delete=models.CASCADE) b = models.ForeignKey(B, related_name="As_through", on_delete=models.CASCADE) I would like to be able to filter all objects (A, B, A2B) that are valid on a given day in an easy way, something like: with ValidityMixinModel.valid_on_context_manager(date(2018,11,23)): # only display objects A with their related Bs # as if A, B and A2B instances had all the filter # validity_range__contains=DateRange(date(2018,11,23),date(2018,11,24)) print(A.objects.prefetch_related("Bs").all()) Any idea on how to do this ? -
How to check which the fields of a form has been modified in Flask?
I am trying to figure out a way to check if there is any built-in Form method that would return true if the form has been modified in Flask/WTForms I know that in Django Forms, we have that flexibility to use form.has_changed() method that would do exactly what i want. I am trying to check if the form has been modified and if it is I would to do some database updates. If anybody has any idea, please let me know about this or suggest the right approach to start with. -
Data parsing and modelling using python+django
1.how to parse data from url http://www.metoffice.gov.uk/climate/uk/summaries/datasets#Yearorder. save data for min,max temps of uk and london region. 3.Create appropriate data model using Django ORM to store the above data. 4.Write code to store all of the downloaded data and ser should be able to run it multiple times without any duplication of data etc. -
Deprecated Package Syntax in Django
I'm using an older textbook, and the guide is telling me to include the following imports in my urls.py from django.views.generic.list.ListView import object_list, object_detail from django.views.generic.create_update import create_update From what I understand, these have been deprecated in an earlier version of Django - but I can't figure out what the modern implementation would be. Any help is appreciated. -
Django ORM Query output is comming strange
I have CampaignEmailTemplate and it has 3 record as below output ==>CampaignEmailTemplate.objects.count() ==>3 2nd query and visible_to is many to many field ==>CampaignEmailTemplate.objects.filter(Q(private_template=True, visible_to=1) | Q(private_template=False)).count() ==>84 I don`t know why its 2nd query is giving me 84 count. It should give me 3 or less. Can anyone help me out to find the real issue with 2nd query. I am using Django==2.0.6 -
Click on row in django-tables2 to take me to another table?
I basically want to click on a row or linked element and take me to another filtered table. For instance, let's say I have a table of genres: Romance Horror Comedy I click on Romance, and then I want a list of all the romance books. How might I do this with django-tables2? How do I get what the user clicked on in my django table? I tried to use table.py class GenreTable(tables.Table): genre = tables.LinkColumn('books_genre_table') class Meta: ... This doesn't work because I can't pass the data and filter it to make a table in the next view/html 'books_genre_table.html' -
I made model migrations during development. Now production database can't detect changes
So I made a few changes to a few models, then made migrations to make sure everything worked locally. Local database is SQLite Then I pushed to github, and then pulled it onto my Digital Ocean VPS. VPS using postgresql Then I tried running makemigrations and it's not detecting any changes. Despite all the files showing the new changes. Did I screw up by making migrations locally? How do I fix this? -
How to return None if no request is made using django-filter
Hello I am a bit puzzled on how to achieve this. I have a filter built with django-filter by default it returns a list of objects in the database. My I don't want to display the list until a filter is made/searched how do I go about that? -
DRF: Object of type 'ListSerializer' is not JSON serializable
I'm new to Django and DRF.While learning I got the error Object of type 'ListSerializer' is not JSON serializable error.I'm not sure from where the error is raising Traceback: File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 217. response = self.process_exception_by_middleware(e, request) File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 215. response = response.render() File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/django/template/response.py" in render 107. self.content = self.rendered_content File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/rest_framework/response.py" in rendered_content 72. ret = renderer.render(self.data, accepted_media_type, context) File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/rest_framework/renderers.py" in render 718. context = self.get_context(data, accepted_media_type, renderer_context) File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/rest_framework/renderers.py" in get_context 675. 'content': self.get_content(renderer, data, accepted_media_type, renderer_context), File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/rest_framework/renderers.py" in get_content 416. content = renderer.render(data, accepted_media_type, renderer_context) File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/rest_framework/renderers.py" in render 105. allow_nan=not self.strict, separators=separators File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/rest_framework/utils/json.py" in dumps 28. return json.dumps(*args, **kwargs) File "/usr/lib/python3.6/json/__init__.py" in dumps 238. **kw).encode(obj) File "/usr/lib/python3.6/json/encoder.py" in encode 201. chunks = list(chunks) File "/usr/lib/python3.6/json/encoder.py" in _iterencode 437. o = _default(o) File "/home/marvel/venv/django_1_111/lib/python3.6/site-packages/rest_framework/utils/encoders.py" in default 68. return super(JSONEncoder, self).default(obj) File "/usr/lib/python3.6/json/encoder.py" in default 180. o.__class__.__name__) Exception Type: TypeError at /sample/view/ Exception Value: Object of type 'ListSerializer' is not JSON serializable and here is my code samples #serializer.py class SampleSerializer(serializers.ModelSerializer): class Meta: fields = '__all__' model = SampleModel #views.py @api_view(http_method_names=['GET']) def my_view(request): qs = SampleModel.objects.all() serializer = SampleSerializer(qs, many=True) return Response(serializer) -
MailChimp: how to authenticate in django?
I've a list in MailChimp I want to complete with emails through a Subscribe Form on my template. I was watching a tutorial on this, made everything as expected, but cannot send the data to MailChimp. My View send the subscribed user to my DB and to MailChimp's DataBase through it's API. I know that the problem is with the function that sends the data to MailChimp because when commenting it's line I can save the email in my DB. So my problem is in my subscribe function. When I comment the line where I call it in my other function email_signup_form everything works ok (But no data is send to MailChimp). ERROR: TypeError at /suscribirse/ 'module' object is not callable Importart: -This is the tutorial I was following: https://www.youtube.com/watch?v=2KeV42YaPes -I think the problem is with the function auth in subscribe function. I didn't see when he called it so I thought to import it from django.contrib, but I'm guessing it only authenticates the Django functions. from django.shortcuts import render from django.conf import settings from django.contrib import auth, messages from django.http import HttpResponse import json import requests from django.views.decorators.csrf import csrf_exempt from .forms import EmailSignUpForm from .models import SignUp from … -
Combining date and time into datetimefield
I am trying to combine my date input and time input, into a datetime field I have in my model. I am receiving the error, combine() argument 1 must be datetime.date, not Booked, and am not sure if it is from the book.booked_datetime part of my view or the datetime.combine(date, time) part. I would appreciate any help in merging my date and time field into datetime, models.py class Booked(models.Model): teacher_user = models.ForeignKey(User, null=True, default=None, related_name='book1', on_delete=models.CASCADE) student_user = models.ForeignKey(User, null=True, default=None, related_name='book2', on_delete=models.CASCADE) booked_instrument = models.CharField(max_length=255, blank=True) booked_length = models.CharField(max_length=255, choices=length_list, blank=True) booked_date = models.DateField(null=True, blank=True) booked_time = models.TimeField(null=True, blank=True) booked_datetime = models.DateTimeField(null=True, blank=True) forms.py class BookedForm(forms.ModelForm): booked_instrument = forms.CharField(widget=forms.TextInput(attrs={'class' : 'form-control'})) booked_length = forms.ChoiceField(choices=length_list, widget=forms.Select(attrs={'class' : 'form-control', 'id' : 'length', 'required' : 'True'})) booked_date = forms.DateField(input_formats=['%b. %d, %Y'], widget=forms.DateInput(attrs={'class': 'form-control', 'name' : 'date'})) booked_time = forms.ChoiceField(choices=time_list, widget=forms.Select(attrs={'class' : 'form-control', 'id' : 'time', 'name' : 'time', 'required' : 'True'})) views.py def book_lesson(request, lesson_id): if request.user.is_authenticated and request.user.time_zone: activate(request.user.time_zone) else: deactivate() lesson = Lesson.objects.get(id=lesson_id) if request.method == 'POST': form = BookedForm(request.POST) if form.is_valid(): book = form.save(commit=False) date = request.POST.get('date') time = request.POST.get('time') book.booked_datetime = datetime.combine(date, time) book.student_user = request.user book.teacher_user = lesson.user book.save() messages.success(request,'Lesson was successfully booked!') return redirect('/teacher/dashboard') else: form … -
Filling empty column value with 0 or Null in Python CSV writter
I am creating a CSV file in python and writing data using Django model and SQL server. I have a few null values in the database. when I write CSV file it writes nulls as ''(empty). how can I fill up the empty field in CSV with "Null" or "0"? with open(f'{store_data}/test.csv', 'w', encoding='utf-8') as dataFile: task_data = MonitorItem.objects.all() wr = csv.writer(dataFile) # wr.writerow(taskHeaders) for t in task_data: wr.writerow([t.x, t.y, t.z]) -
How to make option in select menu point to Django URL
I have this view as context_processors.py which means I can present an archive as a drop - down menu in a select html tag. def blogposts_processor(request): blogposts = BlogPost.objects.all() q=blogposts.dates('date', 'month') s = [(i.strftime('%b'),i.strftime('%Y')) for i in q] return {'blogposts': blogposts,'s':s} I have already present the dates like Feb 2018, Apr 2018 etc: <script> var n =[{% for i in q %}"{{ i|safe }}"{% if not forloop.last %},{% endif %}{% endfor %}]; var k=[]; var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var dynamicSelect = document.getElementById("selectdate"); n.forEach(function(entry){ a = new Date(entry); amonth= months[a.getMonth()]; ayear = a.getFullYear(); c = amonth + " " + ayear; k.push(c); var newOption = document.createElement("option"); newOption.text = c; dynamicSelect.add(newOption); </script> Now my url for archive is url(r'^(?P<year>[0-9]{4})/(?P<month>[-\w]+)/$', BlogPostMonthArchiveView.as_view(), name="blogpost_month_archive"), I want each option in the select drop down menu to link to the correct archive. So each option in the menu should have URL {% url 'home:blogpost_month_archive' year='ayear' month='amonth' %} I have made a start and looked for solution here var url = "{% url 'home:blogpost_month_archive' year='2018' month='Feb' %}" var year = $(this).attr('ayear'); var month = $(this).attr('amonth'); document.location.href = url.replace('2018', year).replace('Feb', month); I'm not too far away, I just … -
Paypal Python SDK 'Payment' object has no attribute 'create'
I'm trying to run this code. payment = Payment({ "intent": "sale", "payer": { "payment_method": "paypal" }, # Set redirect URLs "redirect_urls": { "return_url": "http://uwus.me:40/processagreement/", "cancel_url": "http://uwus.me:40/" }, # Set transaction object "transactions": [{ "amount": { "total": "100.00", "currency": "USD" }, "description": "Voxitus Yearly License is a digital product for the website voxitus.com/voxit.us." }] }) if payment.create(): # Extract redirect url for link in payment.links: if link.method == "REDIRECT": # Capture redirect url redirect_url = (link.href) return redirect(redirect_url) # Redirect the customer to redirect_url I'm not sure how to fix this, as it says that the "create" function does not exist. I've googled it but I can't seem to find or see anything that works. I'm using Django. -
Django: get foreign key data to display in Angular
I am trying to retrieve all columns of a table through a foreign key relationship and am wondering how to do so. I have the following code: models.py class Athletes(models.Model): athlete_id = models.AutoField(db_column="AthleteID", primary_key="True") first_name = models.CharField(db_column='FirstName', max_length=100) last_name = models.CharField(db_column='LastName', max_length=100) def __str__(self): return str(self.athlete_id) + ' ' + self.first_name + ' ' + self.last_name class Meta: managed = True db_table = 'Athletes' ordering = ('athlete_id', ) class VelocityLoadPredict(models.Model): vl_predict_id = models.AutoField(db_column="vl_predict_id", primary_key="True") athlete_id = models.ForeignKey(Athletes, on_delete=models.CASCADE, db_column="athleteID") lift_name = models.CharField(db_column="LiftName", max_length=100) def __str__(self): return str(self.vl_predict_id) class Meta: managed = True db_table = 'velocity_load_predict' ordering = ('vl_predict_id', ) And I am using serializers: class AthletesSerializer(serializers.ModelSerializer): class Meta: model = Athletes fields = ('athlete_id', 'first_name', 'last_name') class VelocityLoadPredictSerializer(serializers.ModelSerializer): class Meta: model = VelocityLoadPredict fields = ('vl_predict_id', 'athlete_id', 'lift_name') In Angular I have the following code (api.service): analytics.component.ts analytics: Analytics[]; constructor(private data: DataService, private api: ApiService) { this.getAnalytics(); } getAnalytics = () => { this.api.getAnalytics().subscribe( data => { this.analytics = data; }, error => { console.log(error); } ); I then want to represent the first name, last name and lift name in my html analytics file: <p *ngFor='let element of analytics'>{{element.first_name}}</p> How do I go about doing that when the Athletes …