Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Pass Django variables to javascripts
I am stuck into a problem, I want to pass django variable to javascripts but I can't. views.py def dashboard_view(request): months_before = 5 now = datetime.utcnow() from_datetime = now - relativedelta(months=months_before) modified_from_datetime = from_datetime.replace(day=1, hour=0, minute=0, second=0, microsecond=0) month = Btdetail.objects.filter(DatePur__gte=modified_from_datetime).count() return render(request, "dashboard.html", {'month': month}) I want to embed month value to javascripts data my html script function is <script> var xValues = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; new Chart("myChart3", { type: "line", data: { labels: xValues, datasets: [{ data: [5,10,20,15,20,5,15,40,10,12,24,35], borderColor: "red", fill: false }] }, options: { legend: {display: false} } }); </script> actually I want to create a Area bar, all things are good but javascript functions cant get value from django database and if there is another way to do this please tell me [1]: https://i.stack.imgur.com/9bJzE.jpg -
Slow spatial join on a single table with PostGIS
My goal is to calculate if a building have at least one shared wall with a building of another estate. I used a PostGIS query to do so but it is really slow. I have tweaked this for two weeks with some success but no breakthrough. I have two tables: Estate (a piece of land) CREATE TABLE IF NOT EXISTS public.front_estate ( id integer NOT NULL DEFAULT nextval('front_estate_id_seq'::regclass), perimeter geometry(Polygon,4326), CONSTRAINT front_estate_pkey PRIMARY KEY (id), ) CREATE INDEX IF NOT EXISTS front_estate_perimeter_idx ON public.front_estate USING spgist (perimeter); Building CREATE TABLE IF NOT EXISTS public.front_building ( id integer NOT NULL DEFAULT nextval('front_building_id_seq'::regclass), type character varying(255) COLLATE pg_catalog."default", footprint integer, polygon geometry(Polygon,4326), shared_wall integer, CONSTRAINT front_building_pkey PRIMARY KEY (id) ) CREATE INDEX IF NOT EXISTS front_building_polygon_idx ON public.front_building USING spgist (polygon) TABLESPACE pg_default; CREATE INDEX IF NOT EXISTS front_building_type_124fcf82 ON public.front_building USING btree (type COLLATE pg_catalog."default" ASC NULLS LAST) TABLESPACE pg_default; CREATE INDEX IF NOT EXISTS front_building_type_124fcf82_like ON public.front_building USING btree (type COLLATE pg_catalog."default" varchar_pattern_ops ASC NULLS LAST) TABLESPACE pg_default; The m2m relation: CREATE TABLE IF NOT EXISTS public.front_estate_buildings ( id integer NOT NULL DEFAULT nextval('front_estate_buildings_id_seq'::regclass), estate_id integer NOT NULL, building_id integer NOT NULL, CONSTRAINT front_estate_buildings_pkey PRIMARY KEY (id), CONSTRAINT front_estate_buildings_estate_id_building_id_863b3358_uniq UNIQUE … -
Authorization: Any Benefit of OAuth2 for First-Party Web and Mobile Clients
I would like to know whether there is any security benefit to using OAuth2 for authorization where all clients are developed, owned and controlled by the API developer/owner/controller; as opposed to using token authentication per Django Rest Framework's Token Authentication. My understanding OAuth is that it was created for the purpose of delegated authorization - allowing third party applications access to your user's data without knowing the user's credentials. It seems to now have become a standard, even where delegation is not required. I do not understand why. Is there any benefit at all where delegation is not required? My setup will be a Django Rest Framework API with a web SPA client and mobile clients. Permissions are associated with user accounts. Users login with email and password. I do not think that this is an opinion question, because I'm not asking which is better, I will make that decision myself, I'm just trying to understand whether there is actually any security benefit at all to the OAuth option. This question might be somewhat open-ended but hopefully is within an acceptable margin since I'm restricting the considerations to security considerations. Developer effort etc are not necessary to discuss. -
Django form for user input to database
I am attempting to have a form which users can create new orders. The user gives the order a name, submits the form and then auto populates the creation date and user who created it. Additionally, I want the form to be on the same page as the contents of the database, so that a list of all orders can be displayed underneath. When the form is submitted, the page should refresh to show the new entry. I need a bit of help tying all this together. At the moment, I am not getting the form displayed on the site for the users to fill in. models.py from django.db import models from django.contrib.auth.models import User from django.forms import ModelForm class Order(models.Model): order_name = models.CharField(max_length=100, unique=True, null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) created_by = models.ForeignKey(User, related_name='Project_created_by', on_delete=models.DO_NOTHING) def __str__(self): return self.order_name class Ce_Base(models.Model): ce_hostname = models.CharField(max_length=15) new = models.BooleanField() location = models.TextField() order_reference = models.ManyToManyField(Order) class OrderForm(ModelForm): class Meta: model = Order fields = ['order_name'] views.py from django.shortcuts import render from django.contrib.auth.decorators import login_required from .models import Order from .models import Ce_Base from .forms import OrderForm @login_required def home(request): context = { 'order': Order.objects.all() } return render(request, 'orchestration/order_create.html', context) @login_required def orderprocessing(request): … -
TypeError: Object of type SMTPAuthenticationError is not JSON serializable
Below is my code for sending email through django but I am getting TypeError: Object of type SMTPAuthenticationError is not JSON serializable error. Anyone can tell me what I am doing wrong? from django.core.mail import send_mail, EmailMultiAlternatives from django.conf import settings @api_view(['POST']) def sendEmail(request, version): print(request.data) emailSubject = request.data['emailSubject'] emailMessage = request.data['emailMessage'] emailRecipient = request.data['emailRecipient'] print(settings.EMAIL_FROM) try: send_mail( emailSubject, emailMessage, settings.EMAIL_FROM, [emailRecipient] ) return Response( { "message": "Email sent successfully" }, status=status.HTTP_200_OK ) except Exception as ex: return Response( { "message": ex }, status=status.HTTP_409_CONFLICT ) Error Response: May 12, 2022 - 16:32:04 Django version 3.1.6, using settings 'bumpdate.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. {'emailSubject': 'Testing Subject', 'emailMessage': 'Testing Message in the email body', 'emailRecipient': 'muzaib.a@origamistudios.us'} hello@bumpdateapp.com [12/May/2022 16:32:40] ERROR [django.request:224] Internal Server Error: /api/v2/sendEmail Traceback (most recent call last): File "D:\PROJECTS\bumpDate\venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "D:\PROJECTS\bumpDate\venv\lib\site-packages\django\core\handlers\base.py", line 204, in _get_response response = response.render() File "D:\PROJECTS\bumpDate\venv\lib\site-packages\django\template\response.py", line 105, in render self.content = self.rendered_content File "D:\PROJECTS\bumpDate\venv\lib\site-packages\rest_framework\response.py", line 70, in rendered_content ret = renderer.render(self.data, accepted_media_type, context) File "D:\PROJECTS\bumpDate\venv\lib\site-packages\rest_framework\renderers.py", line 100, in render ret = json.dumps( File "D:\PROJECTS\bumpDate\venv\lib\site-packages\rest_framework\utils\json.py", line 25, in dumps return json.dumps(*args, **kwargs) File "C:\Python39\lib\json\__init__.py", line 234, in dumps return cls( File "C:\Python39\lib\json\encoder.py", … -
How to access dictionary element from html?
I have python dictionary and I wanted to access a deep field of it in html. dictionary - dictionary = {"album":{ "album_type":"single", "images": [ { "height": 640, "url": "https://i.scdn.co/image/ab67616d0000b273358193d702a21397291432ef", "width": 640 }, { "height": 300, "url": "https://i.scdn.co/image/ab67616d00001e02358193d702a21397291432ef", "width": 300 }, { "height": 64, "url": "https://i.scdn.co/image/ab67616d00004851358193d702a21397291432ef", "width": 64 }] } } I wanted to access the image url, I know how to do that in python like- dictionary["album"]["images"][0]['url'] But don't know how to do it in html. NOTE: I am using Django Framework Thanks in Advance! -
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 75: invalid continuation byte [closed]
the project works with generated text, but when I start writing text it crashes with an English text it works correctly, but in French I have this error thank you for your help return fp.read() \Python\Python39\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 75: invalid continuation byt lib\site-packages\django\template\loaders\base.py", line 23, in get_template contents = self.get_contents(origin) lib\site-packages\django\template\engine.py", line 158, in find_template template = loader.get_template(name, skip=skip) lib\site-packages\django\template\engine.py", line 176, in get_template template, origin = self.find_template(template_name) lib\site-packages\django\template\backends\django.py", line 34, in get_template return Template(self.engine.get_template(template_name), self) lib\site-packages\django\template\loader.py", line 15, in get_template return engine.get_template(template_name)``` -
How to fix ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: when installing python packages on Zorin 16
How to fix ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: when installing python packages on Zorin 16. I was installing postgresql's psycopg2 to connect my postgres Database to Django. I got this error and suddenly every pip package i try gives me the same issue. I check online the answers where too old and can't work. My system is Zorin 16 Debian/Ubuntu. source myenv/bin/activate pip3 install psycopg2-binary ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/dukula/Area/myenv/lib/python3.8/site-packages/psycopg2-2.9.3.dist-info' Consider using the `--user` option or check the permissions. -
How to create a child at the time of creating a parent - Django
I have two models and I don't know how to create an 'ExDocument' child associated with its field extension when creating the parent 'Document'. Document: class Document(models.Model): name = models.CharField(max_length=255) documentId = models.CharField(max_length=50, blank=True, null=True, default=None) text = models.CharField(max_length=2555) owner = models.ForeignKey(User, related_name="Doc_Own", blank=True, null=True, default=None, on_delete=models.CASCADE) author = models.ForeignKey(User, related_name="Doc_Aut", blank=True, null=True, default=None, on_delete=models.CASCADE) def save(self, **kwargs): super().save(**kwargs) def __str__(self): return self.name ExDocument: class ExDocument(models.Model): doc_name = models.CharField(max_length=255, null=True, blank=True) ex_name = models.OneToOneField(Document, related_name='ExDoc', on_delete=models.CASCADE) def __str__(self): return self.ex_name.name def delete(self, *args, **kwargs): super().delete(*args, **kwargs) if self.ex_name: self.ex_name.delete() -
I am trying to set a user from my custom django signup form based on what option they select from a RadioButton
My forms.py users = [ ('client', 'Client'), ('customer', 'Customer'), ] class CustomSignUpForm(SignupForm): Register_as = forms.ChoiceField(choices=users, widget=forms.RadioSelect) def save(self, request): if CustomSignUpForm.Register_as.widget == 'client': user = super(CustomSignUpForm, self).save(request) user.is_client = True user.save() return user if CustomSignUpForm.Register_as.widget == 'customer': user = super(CustomSignUpForm, self).save(request) user.is_customer = True user.save() return user But after running the code, i get this error AttributeError at /accounts/signup/ type object 'CustomSignUpForm' has no attribute 'Register_as' Request Method: POST Request URL: http://localhost:8000/accounts/signup/ Django Version: 3.2.5 Exception Type: AttributeError Exception Value:type object 'CustomSignUpForm' has no attribute 'Register_as' -
I'm try to deploy my django project in Heroku by use Heroku CLI I face installation error
Everything goes right till I run this command: git push heroku master I get this massages: git push heroku master Enumerating objects: 55, done. Counting objects: 100% (55/55), done. Delta compression using up to 8 threads Compressing objects: 100% (46/46), done. Writing objects: 100% (55/55), 15.40 KiB | 685.00 KiB/s, done. Total 55 (delta 14), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-20 stack remote: -----> Determining which buildpack to use for this app remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. remote: Detected buildpacks: Python,Node.js remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order remote: -----> Python app detected remote: -----> No Python version was specified. Using the buildpack default: python-3.10. remote: To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes remote: -----> Installing python-3.10.4 remote: -----> Installing pip 22.0.4, setuptools 60.10.0 and wheel 0.37.1 remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: Collecting argcomplete==1.8.1 remote: Downloading argcomplete-1.8.1-py2.py3-none-any.whl (34 kB) remote: Collecting argh==0.26.2 remote: Downloading argh-0.26.2-py2.py3-none-any.whl (30 kB) remote: Collecting attrs==19.3.0 remote: Downloading attrs-19.3.0-py2.py3-none-any.whl (39 kB) remote: Collecting Automat==0.8.0 remote: Downloading Automat-0.8.0-py2.py3-none-any.whl (31 kB) remote: Collecting blessings==1.6 remote: … -
Django & Ajax - "Like" button, how to make it work for mutliple posts on a page?
There are a lot of similar questions already raised, but so far haven't managed to fix my setup. I successfully created a 'like' button with a counter, but it works only on one post, where there are multiple on one page (while hitting the like button on another post, only the first one gets changed). What should I change in the code, to make it work for all posts? HTML button {% for news in newss %} <div class="col-md-6"> {% csrf_token %} <button class="like-button" value="{{ news.id }}" > Like </button> <span class="" id="like_count">{{ news.news_likes_count }}</span> </div> {% endfor %} AJAX <script> $(document).on('click', '.like-button', function (e) { e.preventDefault(); $.ajax({ type: 'POST', url: '{% url "like" %}', data: { newsid: $('.like-button').val(), csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(), action: 'post' }, success: function (json) { document.getElementById("like_count").innerHTML = json['result'] }, error: function(xhr, errmsg, err) { } }); }) </script> views.py @login_required def like(request): if request.POST.get('action') == 'post': result = '' id = int(request.POST.get('newsid')) news = get_object_or_404(News, id=id) if news.news_likes.filter(id=request.user.id).exists(): news.news_likes.remove(request.user) news.news_likes_count -= 1 result = news.news_likes_count news.save() else: news.news_likes.add(request.user) news.news_likes_count += 1 result = news.news_likes_count news.save() return JsonResponse({'result': result,}) urls.py path('like/', views.like, name='like') models.py class News(models.Model): news_title = models.CharField(max_length=100) news_text = models.TextField(max_length=2000) news_author = models.CharField(max_length=150) news_created_date = models.DateTimeField(default=now) … -
Why django refuses to see a folder?
Django just refuses to see libs module. Idk why it happens, it definitely kidding me. The structure goes like django app struct Can somebody tell me why exactly it happens? -
Save Data from Rest API to database using Django(view function)
I am trying to save API data to the database. I can with the print function, but I want to save without the print function. -
Partial loading using javascript in django
I have two html pages index.html and user.html. user.html contains search action.Here I've loaded user.html in index.html using jQuery.When I perform search action it's redirecting to user.html...But I want to display result in the index.html.The project is in django.Is there is any way to do this?? -
Dockerizing Django with nginx and gunicorn
This is a very basic django deployment and I am trying to configure nginx and gunicorn on it through docker It seems to run fine but there is no connection. folder path: Dockerized-Django ├── Dockerfile ├── docker-compose.yml ├── entrypoint.sh ├── nginx │ ├── Dockerfile │ └── default.conf ├── pyshop │ ├── db.sqlite3 │ ├── manage.py │ ├── products │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── admin.cpython-38.pyc │ │ │ ├── apps.cpython-38.pyc │ │ │ ├── models.cpython-38.pyc │ │ │ ├── urls.cpython-38.pyc │ │ │ └── views.cpython-38.pyc │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── 0002_offer.py │ │ │ ├── 0003_auto_20220507_1845.py │ │ │ ├── __init__.py │ │ │ └── __pycache__ │ │ │ ├── 0001_initial.cpython-38.pyc │ │ │ ├── 0002_offer.cpython-38.pyc │ │ │ ├── 0003_auto_20220507_1845.cpython-38.pyc │ │ │ └── __init__.cpython-38.pyc │ │ ├── models.py │ │ ├── templates │ │ │ ├── base.html │ │ │ └── index.html │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py │ └── pyshop │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── settings.cpython-38.pyc … -
How to configure Ngnix server with django-channels-redis
I'm trying to to configure my django chat app using django-channels and redis with ngnix server, How can I achieve this? -
Sort django admin column by __str__ method
I have a Folder model and I want to display the columns in the admin page ordered alphabetically following the __str__ method. I looked over several similar questions like this one, this one and also this one, but didn't manage to really understand the answers, or at least enough to adapt them to my problem (even though I've been trying for quite some time). Here is my Folder class, with the str method I want to sort with : class Folder(models.Model): folder_name = models.CharField(max_length=200) parent_folder = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True) def __str__(self): if self.parent_folder: return f'{self.parent_folder}/{self.folder_name}' else: return self.folder_name And my FolderAdmin class : class FolderAdmin(admin.ModelAdmin): ordering = ('str',) #I want it to do like that but don't know how to do it fieldsets = [ (None, {'fields': ['folder_name']}), ('Parent Folder', {'fields': ['parent_folder']}), ] list_display = ('folder_name', '__str__') I feel dumb for not understanding a question already answered multiple times but if you could help me understand it I'd be grateful. Thank you in advance ! -
when i remove a field my manage.py migrate raise django.db.utils.ProgrammingError
I got a problem with python manage.py migrate when I removed the field name from the oldest model. python 3.8 Dajngo 4.0.4 PostgreSQL 12 ubuntu 20.04 oldest model class BaseModel(models.Model): name = models.CharField(verbose_name=_("Name"), unique=True, max_length=255) created_time = models.DateTimeField(verbose_name=_("Created time"), auto_now_add=True) is_active = models.BooleanField(verbose_name=_("Is active"), default=True) Report model before the change class Report(BaseModel): reporter = models.ForeignKey( to="User",related_name="reporter_user", on_delete=models.CASCADE ) reported = models.ForeignKey( to="User",related_name="reported_user", on_delete=models.CASCADE ) description = models.TextField(null=True, blank=True) Repot model after change: class Report(BaseModel): name = None reporter = models.ForeignKey( to="User",related_name="reporter_user", on_delete=models.CASCADE ) reported = models.ForeignKey( to="User",related_name="reported_user", on_delete=models.CASCADE ) description = models.TextField(null=True, blank=True) python manage.py makemigrations was done successfully but when I wanted to migrate them I got this error: django.db.utils.ProgrammingError: column "name" of relation "user_report" does not exist what's my problem? -
Whats a good pattern for a web-application for serving files?
I am working on an angular Web-Application where it's possible to view pdf-files in a pdf-viewer in the browser. The Web-Application is also consuming a REST-Service in Django. In the Database the information of the pdf-files is stored. The Web-App is calling the REST-API to check where the files are stored. As I am still in the Proof-Of-Concept Phase of the project, the PDF-Files are currently stored in the assets folder of the angular web, which of course is not what I want in the end. When the Files or the Directories change, the Database should be updated automatically (or via a trigger in the app). I have two questions: Is there an obvious way to serve the files in this combination? i.e. an apache server? I imagine there are built in solutions in dedicated file servers to detect changes of the watched directory. For a partly solution would it be reasonable to write a script on the django site, which does the file-serving, the updating and also providing the REST-API? -
Django: form not showing up in rendered template
I tried to add a page in my admin panel for the user to upload a CSV file. However, the form I passed into the template is not displayed, although I followed this tutorial. https://www.youtube.com/watch?v=BLxCnD5-Uvc&t=340s (From around 14:20 to 17:30) I checked if the context containing the form is correctly passed into the template by passing in a random text, but that random text was displayed in my template and it was just the form that is not being rendered. This is my admin.py: class CsvImportForm(forms.Form): csv_upload = models.FileField() class UserAdmin(BaseUserAdmin): form = UserChangeForm add_form = UserCreationForm list_display = ('email', 'first_name', 'middle_name', 'last_name', 'role', 'subject', 'schedule_uploaded', 'is_admin') list_filter = ('is_admin',) fieldsets = ( (None, {'fields': ('email', 'password', 'first_name', 'middle_name', 'last_name', 'role', 'subject', 'schedule_uploaded')}), ('Permissions', {'fields': ('is_admin',)}) ) add_fieldsets = ( (None, { 'classes': ('wide',), 'fields': ('email', 'password1', 'password2', 'first_name', 'middle_name', 'last_name', 'role', 'subject', 'schedule_uploaded', 'is_admin')} ), ) search_fields = ('email', 'first_name', 'middle_name', 'last_name', 'role', 'subject', 'schedule_uploaded') ordering = ('email', 'first_name', 'middle_name', 'last_name', 'role', 'subject', 'schedule_uploaded') filter_horizontal = () def get_urls(self): urls = super().get_urls() new_urls = [path('csv_upload/', self.csv_upload)] return new_urls + urls def csv_upload(self, request): form = CsvImportForm() context = {"form": form} return render(request, 'admin/csv_upload.html', context) This is my template: {% … -
How to access one Django Project Database from another Django Project?
I am trying to access one Django Project Database value from another Django Project. So far I have tried making REST API on both the applications and it is working somewhat well on the local server. However, I am concerned that when I will be deploying both the projects on the server it will create some lag to access over the API. Moreover, if one server/application is down for maintenance, the other will be inaccessible. Is it possible to directly access the other app database without using API as it will be much more faster and reliable? Thanks. -
How to display different data according to users in android using get method?
For my app, in user registration, when a user registers in the app, their data is sent to database and stored there and using GET method it is displayed in the app, Now how do I display the data in my app differently for different users because each users have their own unique data, and what I need is to display profile description of whoever fills the form. (I am using android studio and java to make android app) -
Unicode in Content-Disposition in Post-IE11 area
Accoding to this old answer you need to encode a unicode filename like this: from urllib.parse import quote disposition = 'attachment' if as_attachment else 'inline' try: filename.encode('ascii') file_expr = 'filename="{}"'.format(filename) except UnicodeEncodeError: file_expr = "filename*=utf-8''{}".format(quote(filename)) response.headers['Content-Disposition'] = '{}; {}'.format(disposition, file_expr) Just for fun I tried this: response = HttpResponse('abcd') response['Content-Disposition'] = b'attachment; filename="{}"'.format('üöä & €.txt'.encode('utf8')) return response And Chrome, Firefox and Epiphany (WebKit) where able to download the file to üöä & €.txt. Which (not outdated) http clients have trouble with this simple utf-8 encoded filename? -
Using Django ORM to sum annotated queries
I am using Django in combination with a TimescaleDB to process energy data from pv installations. Now I would like to calculate, how much energy multiple plants have generated within a given timebucket (usually per day). The plants writing the new values in a table which looks like that: customer datasource value timestamp 1 1 1 01.05.22 10:00 1 1 5 01.05.22 18:00 1 2 3 01.05.22 09:00 1 2 9 01.05.22 17:00 1 1 5 02.05.22 10:00 1 1 12 02.05.22 18:00 1 2 9 02.05.22 09:00 1 2 16 02.05.22 17:00 Now what I would like to have is, get the overal daily gain of values (so, for each day: Last Entry Value - (minus) First Entry Value) for each customer (which means, sum the daily generated energy values from all datasource which belong to the customer). In the above example that would be for customer 1: Day 01.05.22: Daily Gain of Datasource 1: 5 - 1 = 4 Daily Gain of Datasource 2: 9 - 3 = 6 Overall: 4 + 6 = 10 Day 02.05.22: Daily Gain of Datasource 1: 12 - 5 = 7 Daily Gain of Datasource 2: 16 - 9 = 7 Overall: …